Stage 1 · Code
Graph Algorithms
BFS
Breadth-first search for shortest path in unweighted graphs.
BFS Basics
BFS explores level by level using a queue. Visits all nodes at distance d before distance d+1. Guarantees shortest path in unweighted graphs.
Shortest Path
Track parent array to reconstruct path. Distance array gives shortest distance from start.
Multi-Source BFS
Start with multiple sources in queue. All sources distance 0. Propagates simultaneously. Distance to nearest source.
0-1 BFS
For graphs with edge weights 0 or 1. Use deque: push 0-weight edges to front, 1-weight to back. Processes nodes in increasing distance order. O(V+E).
Mark this lesson complete to store local progress and unlock a cleaner resume path the next time you visit.