DSAVisualiseData Structures & Algorithms Studio
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 JSON

Edit the lesson input, then build a deterministic source-linked trace.

This lesson validates its own input and operation limits.

Source scenarios

Complexity

BestΘ(RC)
AverageΘ(RC)
WorstΘ(RC)
SpaceΘ(RC)

Array state

Follow the active comparisons and writes.

Live snapshot

Current operation

Trace state
Ready 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

Java
GlobalWarmingPaths.javaStep linked
The highlighted line follows the current step.

Ready to begin

Press Play to see what happens.

Detailed execution
Snapshot 1 / 1