Graphs & Connectivity Hard
Multi-Source BFS: Wildfire Simulation
A multi-source BFS spreads from every burning tree, one orthogonal tree cell per minute.
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
Find how many minutes until every reachable tree burns, or -1 when isolated trees remain.
- Starting from only one burning cell.
- Letting fire spread through empty cells.
- Using diagonal adjacency.
Algorithm code
JavaWildfire.javaStep linked
The highlighted line follows the current step.
Ready to begin
Press Play to see what happens.
Detailed execution
Snapshot 1 / 1