Question: In Lecture 1 7 , we saw a magic trick that can turn a BFS algorithm into a DFS algorithm by simply replacing the queue
In Lecture we saw a magic trick that can turn a BFS algorithm into a DFS algorithm
by simply replacing the queue with a stack. But I mentioned that this magic trick does not
work for all BFS algorithms. In this problem, we will see why.
Below is the BFS algorithm from Lecture but with the queue replaced by a stack
attempting to make it into a DFS Find a counterexmaple, ie construct a graph
can be either directed or undirected such that for some vertex running
VISIT does not correctly give you a DFS tree. The issue is with the sequence
of vertices that you visit, so you may safely ignore the tealcolored lines for the distances.
You should specify the graph drawing it out is fine and the vertex that you run
DFS on along with a quick explanation of what goes wrong with the incorrect DFS tree
it produces.
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
