AlgoScope

Permutations

AlgorithmintermediateBacktracking

Swap each remaining element into the next position, recurse, and swap back; n! leaves.

Decision · step 2 of 32Enumeration: All orderings of three
102132i

Position 0: keep 1 where it is and fix it. Recurse on positions 1 onward.

Open in the player →or start at step 2

What you will see

The tree fans out by remaining choices; a used-set blocks repeats.

How enumeration works →

Cost

BestO(n * n!)
AverageO(n * n!)
WorstO(n * n!)
SpaceO(n)

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.

Before this

Taught by the same lesson

Enumeration covers these too, in the same run.