AlgoScope

Combinations

AlgorithmintermediateBacktracking

Choose k of n in increasing index order so each combination appears once; prune when too few remain.

Decision · step 2 of 24Enumeration: Choose 2 of 4
10213243i

Take a[0] = 1: chosen is {1}. Candidates from now on start at index 1, so nothing to the left can be picked again.

Open in the player →or start at step 2

What you will see

Only branches with larger indices are explored, so each combination appears once.

How enumeration works →

Cost

BestO(C(n, k) * k)
AverageO(C(n, k) * k)
WorstO(C(n, k) * k)
SpaceO(k)

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

Leads to

Topics that need this one first.

Taught by the same lesson

Enumeration covers these too, in the same run.