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

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

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

Ready to begin

Press Play to see what happens.

Detailed execution
Snapshot 1 / 1