When should we use DFS and BFS and in this question can we use BFS?
Graphs with DFS or BFS
Hello @Tejas123, yes you can use dfs as well as bfs for this ques. Generally we can traverse the graph or the tree by using both the aloges but sometimes we need to traverse in such a way such that level one is there then level two , i mean level by level in that case we prefer bfs and in some cases we expect some results from the child and for that we can use dfs, as it can go in one direction first of all then recurring back to the parent and then at next child and so on.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.