Combinations
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
Take a[0] = 1: chosen is {1}. Candidates from now on start at index 1, so nothing to the left can be picked again.
What you will see
Only branches with larger indices are explored, so each combination appears once.
Cost
| Best | O(C(n, k) * k) |
|---|---|
| Average | O(C(n, k) * k) |
| Worst | O(C(n, k) * k) |
| Space | O(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
Taught by the same lesson
Enumeration covers these too, in the same run.