I am trying to state, whether the statement is true:
During a DFS/BFS, first time visited nodes form a spanning tree, that has the same number of edges whether you use DFS or BFS.
Is it true? Thanks!
Sorry I do not understand what this statement means.
– c0der
1 Answers
1
votes
Yes, DFS and BFS generate trees with the same number of edges. DFS and BFS create trees with different shapes. But in both cases, each vertex is connected by an edge with its neighboring vertex. There is no circle in the tree. Then the number of edges should be the same for DFS and BFS.
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.OkRead more