GfG QA is closing soon... Please refer PRACTICE or GfG now on wards !!

Tree in BFS and DFS

What is the difference in the tree formed by bfs and dfs? In the CLRS book, it is written that in dfs, many trees are formed thus forming a forest ,but, in bfs ,one tree is formed.

But according to me, all the vertices that are reachable from the root are part of the same tree in both bfs and dfs. Am I wrong? 

asked Jun 30, 2015 by Richa Tibrewal

1 Answer

It should be forest in both cases.  Seems to be some confusion.  Could you provide exact page number and line number of book where it is written.

 

answered Jun 30, 2015 by learner

Depth first search, pg-603 - 2nd and 3rd paragraph

...