Question: Question 1 : DFS and BFS in Graphs . . . . . . . . . . . . . . . . .
Question : DFS and BFS in Graphs For the following graph problems, design linear time algorithms ie running time OVE or Onm as we have been calling it You should describe each algorithm in English, using around bullets. Do not write code. You can use BFS and DFS as subroutines, without describing them. For each bullet, write down the running time.
In each case, assume that the graph is given to you as an adjacency list.
The goal of this question is for you to learn to think in terms of using standard graph algorithms as "primitives".
For DFSu the output will be a boolean array isReachable where isReachablev is true if v is reachable from u via a directed path and false otherwise. For BFSu the output will be an integer array dist where distv denotes the minimum number of edges in a path from u to v dist v will be INFINITY if v is not reachable from u
a Suppose G is an undirected graph, and let u v be an edge in G Determine if there is a cycle involving ie containing the edge u v in G
b Suppose G is a directed graph and let u be one of the vertices. Let r be a given parameter. Determine if exist paths of length leq r from u to every other vertex in G
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
