Paths & Grids Hard
Multi-Source Dijkstra (Evacuation)
A multi-source Dijkstra search expands outward from all exits and records the next venue toward the closest one.
Trace input
Bounded JSONEdit the lesson input, then build a deterministic source-linked trace.
Source scenarios
Complexity
BestO(V²)
AverageO(V²)
WorstO(V²)
SpaceO(V)
Array state
Follow the active comparisons and writes.
Current operation
Trace stateReady to explore
Source behavior & common mistakes
For every venue, return the next vertex on a least-weight route to any exit; exits use -1 and unreachable venues use -2.
- Starting from each venue separately.
- Confusing the next hop with the previous hop.
- Losing the -1 exit and -2 unreachable sentinels.
Algorithm code
JavaEvacuation.javaStep linked
The highlighted line follows the current step.
Ready to begin
Press Play to see what happens.
Detailed execution
Snapshot 1 / 1