Paths & Grids Hard
Dijkstra: Toroidal Grid Climbing
Dijkstra’s algorithm finds the minimum total height-change cost on a grid that wraps at every edge.
Trace input
Bounded JSONEdit the lesson input, then build a deterministic source-linked trace.
Source scenarios
Complexity
BestO(RC log(RC))
AverageO(RC log(RC))
WorstO(RC log(RC))
SpaceO(RC)
Array state
Follow the active comparisons and writes.
Current operation
Trace stateReady to explore
Source behavior & common mistakes
Find the least sum of absolute height differences between orthogonal neighboring blocks, including toroidal wraparound.
- Forgetting that the mine wraps horizontally and vertically.
- Using the largest single climb instead of summing climb times.
- Processing stale priority-queue entries.
Algorithm code
JavaMineClimbing.javaStep linked
The highlighted line follows the current step.
Ready to begin
Press Play to see what happens.
Detailed execution
Snapshot 1 / 1