Permutations
Swap each remaining element into the next position, recurse, and swap back. n! leaves.
Enumeration: All orderings of three
Position 0: keep 1 where it is and fix it. Recurse on positions 1 onward.
Cost
- Best
- O(n * n!)
- Average
- O(n * n!)
- Worst
- O(n * n!)
- Space
- O(n)
Before this
Taught by the same lesson
Enumeration covers these too, in the same run.