Can BFS be used to find the shortest path between two nodes in an unweighted graph?

  • It depends
  • No
  • Only in directed graphs
  • Yes
Yes, BFS can be used to find the shortest path between two nodes in an unweighted graph. As BFS explores the graph level by level, the first time the destination node is reached, it guarantees the shortest path as it explores nodes in order of their distance from the source.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *