Which traversal is generally suitable for finding the shortest path in an unweighted graph?
Options
- A. DFS
- B. BFS
- C. Quick Sort
- D. More than one of the above
- E. None of the above
Quiz Practice:
B. BFS
BFS can find the shortest path measured by the number of edges in an unweighted graph. It explores vertices in increasing order of their distance from the source: first distance 0, then distance 1, distance 2, and so on. This level-order behavior guarantees that the first time a vertex is reached, its shortest edge-count distance from the source has been found.