Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1 (80p) Consider the graph in Figure 1. We assume that this graph is represented in adjacency list format, with the neighbours in each adjacency
1 (80p) Consider the graph in Figure 1. We assume that this graph is represented in adjacency list format, with the neighbours in each adjacency list sorted in lexicographic order (i.e., in the order a, b, c, d,...), so this is the order in which vertices are encountered when going through neighbour lists 1a (30p) Run the code for depth-first search by hand on this graph, starting in the vertex a. Describe in every recursive call which neighbours are being considered and how they are dealt with. Show the spanning tree produced by the search. 1b (30 p) Run the code for breadth-first search by hand on this graph, also starting in the vertex a. Describe for every vertex which neighbours are being considered and how they are dealt with, and how the queue changes. Show the panning tree produced by the search. 1c (20p) Suppose that the graph in Figure 1 is modified to give every edge weight 1, and that we run Dijkstra's algorithm starting in vertex a. How does the tree computed by Dijkstra's algorithm compare to that produced by DFS? What about BFS? Figure 1: Undirected unweighted graph for graph traversals in Problem 1
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started