Breadth-First Search — interactive algorithm visualization

Medium · Graph · time O(V + E) · space O(V)

Explore a graph in layers using a frontier queue. Visits nodes in non-decreasing distance from the source.

Example input: adjacency = {A:[B,C], B:[D], C:[D,E]}, start = A

Step through a verified execution trace - every step shows the real state, the invariant that keeps the algorithm correct, and asks you to predict what happens next.

Solve Breadth-First Search in the editor · All 16 visualizations

Previous: Two Sum · Next: Connected Components