Graph Theory37 sections · 1633 units
Open in CourseQuiz: BFS Path Reconstruction
Knowledge check
Check Your Understanding
During BFS, you store a parent array where parent[v] records the vertex that discovered v. After BFS finishes, how do you reconstruct the shortest path from source to target?
- A.Follow parent pointers from target back to source, then reverse
- B.Follow parent pointers from source forward to target
- C.Run BFS again from target to source
- D.Sort the parent array by distance