Question: You are given a graph G = (V, E), and you are told that every vertex is reachable from vertex s. You want to determine
You are given a graph G = (V, E), and you are told that every vertex is reachable from vertex s. You want to determine whether the graph has any cycles. Ben Bitdiddle proposes the following algorithm. Perform a BFS from s. If, during the search, you ever reach a node that you have already seen before, then declare that G has a cycle. If you never reach the same node twice, declare that there is no cycle.
1) Show that Bens algorithm works for undirected graphs.
2) Show that Bens algorithm does not work for directed graphs
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
