Breadth-First Search (BFS)
9 min · Scala examples
Explore a graph level by level — shortest steps in an unweighted grid or maze.
Scala · Breadth-First Search (BFS)0/5 cleared
Enemy 1 of 5
BFS uses a queue: visit a node, enqueue all unvisited neighbors, repeat. First time you reach a cell is via the fewest steps (in unweighted graphs).
On a grid, neighbors are usually up/down/left/right.
You
Cargo Cultist
Loading editor...
Ln 1, Col 1Spaces: 4
Sign up to fightTarget output: 4