AlgoScope

Rat in a Maze

AlgorithmintermediateBacktracking

Move through open cells toward the exit; retreat from dead ends.

Decision · step 2 of 8Backtracking: A maze with a dead end
012012111101001

At (0, 0). down is open: step to (1, 0).

Open in the player →or start at step 2

What you will see

The path grows through the grid and retracts from dead ends.

How backtracking works →

Cost

BestO(r * c)
Averageexponential
WorstO(4^(r * c))
SpaceO(r * c)

How you work with it here

play it through, step one change at a time, scrub to any step, run it on your own input, predict what happens next.

Screen readers: Each node of the decision tree announces the choice made and whether it led to success, failure or further choices.

Reduced motion: Tree nodes appear and grey out in place; no travelling focus.

Leads to

Topics that need this one first.

Taught by the same lesson

Backtracking covers these too, in the same run.