DSAVisualiseData Structures & Algorithms Studio
Graphs & Connectivity Hard

Time-Constrained BFS

Breadth-first search finds the fewest one-year jumps while checking each bypass is still open on arrival.

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

BestO(V²)
AverageO(V²)
WorstO(V²)
SpaceO(V)

Array state

Follow the active comparisons and writes.

Live snapshot

Current operation

Trace state
Ready to explore
Source behavior & common mistakes

A bypass from i to j works only when its positive expiration year is greater than the number of years already traveled.

  • Treating every listed bypass as permanently open.
  • Allowing a bypass whose expiry equals the arrival year.
  • Using weighted shortest path when each crossing costs one year.

Algorithm code

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

Ready to begin

Press Play to see what happens.

Detailed execution
Snapshot 1 / 1