Flood Fill
BFS or DFS on a grid, treating same-coloured neighbours as edges.
Decision · step 2 of 12Flood Fill: Fill a region
Pop (0, 0). 2 neighbours still land: (1, 0), (0, 1). Paint and queue them.
What you will see
Colour spreads across the grid from the start cell.
Cost
| Best | O(r * c) |
|---|---|
| Average | O(r * c) |
| Worst | O(r * c) |
| Space | O(r * c) |
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.