Paths & Grids Hard
BFS Grid Shortest Path
Breadth-first search finds the shortest orthogonal route through cells strictly above the water level.
Trace input
Bounded JSONEdit the lesson input, then build a deterministic source-linked trace.
Source scenarios
Complexity
BestΘ(RC)
AverageΘ(RC)
WorstΘ(RC)
SpaceΘ(RC)
Array state
Follow the active comparisons and writes.
Current operation
Trace stateReady to explore
Source behavior & common mistakes
Return the source’s shortest path between two points; wet start cells are still queued by the Java implementation.
- Treating altitude equal to the water level as dry.
- Changing the fixed up/left/down/right neighbor order.
- Assuming Java marks the starting point before it scans neighbors.
Algorithm code
JavaGlobalWarmingPaths.javaStep linked
The highlighted line follows the current step.
Ready to begin
Press Play to see what happens.
Detailed execution
Snapshot 1 / 1