Breadth-First Search
Explore layer by layer with a queue; discovers shortest paths in unweighted graphs.
Dequeue 0, distance 0. Its adjacency list: 1, 2. New: 1, 2, each at distance 1, enqueued.
What you will see
DEQUEUE -> VISIT -> ENQUEUE unvisited neighbours; the frontier expands in rings; queue drawn alongside.
Cost
| Best | O(V + E) |
|---|---|
| Average | O(V + E) |
| Worst | O(V + E) |
| Space | O(V) |
How you work with it here
play it through, step one change at a time, scrub to any step, run it on your own input, predict what happens next, try operations in any order.
Screen readers: Vertices announce name, neighbours and state (in queue, visited, current); each step announces which vertex is processed and which neighbours are discovered.
Reduced motion: Frontier and visited changes are crossfades; the traversal edge is emphasized without a travelling token.
Before this
Leads to
Topics that need this one first.
Taught by the same lesson
BFS and DFS covers these too, in the same run.