Paths & Grids Hard
Computer Virus Propagation
A directed network spreads a virus as servers finish incubating; Dijkstra's priority queue determines the earliest infectious time for every reachable server.
Trace input
Bounded JSONEdit the lesson input, then build a deterministic source-linked trace.
Source scenarios
Complexity
BestO(V + E log V)
AverageO(V + E log V)
WorstO(V + E log V)
SpaceO(V + E)
Array state
Follow the active comparisons and writes.
Current operation
Trace stateReady to explore
Source behavior & common mistakes
Return each reachable server's earliest infectious time. A server starts its incubation when an infectious neighbor reaches it; the start server begins at time zero.
- Recording a server's arrival time without adding its incubation delay.
- Treating directed connections as two-way links.
- Processing every duplicate queue candidate instead of skipping already-infected servers.
- Assuming Dijkstra's earliest-time guarantee holds for negative incubation delays.
Algorithm code
JavaComputerVirus.javaStep linked
The highlighted line follows the current step.
Ready to begin
Press Play to see what happens.
Detailed execution
Snapshot 1 / 1
Visited 0 · Writes 0