{ "q1": { "type": "blank", "question": "\n
Complete the following traversal function, which uses\nfrontier and visited data structures to perform a\ndepth first traversal of a graph (ie. adjacency list):
\n\n\ndef traversal(graph: dict[str, list[str]], source: str) -> None:\n ____ = [source] # 1.\n ____ = set() # 2.\n\n while ____: # 3.\n vertex = ____ # 4.\n\n if vertex in ____: # 5.\n continue\n\n ____ # 6.\n\n print(vertex)\n\n for neighbor in ____: # 7.\n ____ # 8.\n\n" }, "q2": { "type": "multiple", "question": "\n
Given the traversal function above and the frontier\ndata structure used during traversal, which of the following statements\nregarding depth first search, breadth first search,\nDijkstra's algorithm, and Prim's algorithm are true (select\nall that apply)?
\n", "responses": { "dfs_stack": "In depth first search, the frontier is a stack.", "dfs_queue": "In depth first search, the frontier is a queue.", "dfs_priority": "In depth first search, the frontier is a priority queue.", "bfs_stack": "In breadth first search, the frontier is a stack.", "bfs_queue": "In breadth first search, the frontier is a queue.", "bfs_priority": "In breadth first search, the frontier is a priority queue.", "dijkstra_stack": "In Dijkstra's algorithm, the frontier is a stack.", "dijkstra_queue": "In Dijkstra's algorithm, the frontier is a queue.", "dijkstra_priority": "In Dijkstra's algorithm, the frontier is a priority queue.", "prim_stack": "In Prim's algorithm, the frontier is a stack.", "prim_queue": "In Prim's algorithm, the frontier is a queue.", "prim_priority": "In Prim's algorithm, the frontier is a priority queue." } }, "q3": { "type": "multiple", "question": "\nGiven the graph below, which of the following traverals is a valid\ndepth first search starting from vertex A (select all that\napply).
\n\nGiven the same graph above, which of the following traverals is a valid\nbreadth first search starting from vertex A (select all\nthat apply).
\n", "responses": { "a": "A, B, C, D", "b": "A, B, D, C", "c": "A, C, B, D", "d": "A, C, D, B" } }, "q5": { "type": "multiple", "question": "\nGiven the same graph above, which of the following statements regarding\nthe shortest path between A and C are true (select\nall that apply)?\n", "responses": { "sssp_path_ac": "The shortest path between A and is A, C.", "sssp_path_abdc": "The shortest path between A and is A, B, D, C.", "sssp_distance_6": "The shortest path between A and has a distance of 6.", "sssp_distance_5": "The shortest path between A and has a distance of 5." } }, "q6": { "type": "multiple", "question": "\n
Given the same graph above, which of the following statements regarding\nthe minimum spanning tree of the graph (assuming all edges are\nundirected) are true (select all that apply)?\n", "responses": { "mst_ab": "The minimum spanning tree includes the edge A, B.", "mst_ac": "The minimum spanning tree includes the edge A, C.", "mst_bc": "The minimum spanning tree includes the edge B, C.", "mst_bd": "The minimum spanning tree includes the edge B, D.", "mst_cd": "The minimum spanning tree includes the edge C, D." } } }