Which is faster DFS or BFS and why?
It mainly depends on the structure of the tree, both the breadth first search and the depth first search uses the o(v + e) worst time complexicity, if we want the path from the tree then we use breadth first search because and it always gives the shortest path from the starting point to destination node, But the depth first search does not works with the very effecient because the depth first search tree mainly processes the many nodes only based on the stack and but not on the queue
if we are going to search for the shortest nodes the depth first search may be the option
Get Answers For Free
Most questions answered within 1 hours.