Bifalgorithm post · Brisk · Chapter 1
How can permutations be systematically enumerated?
How can permutations be systematically enumerated? (Brisk · Chapter 1) — "We’ve discovered that there are 120 permutations of BRISK, but how would we go about…
Ideas in this flowchart
- Systematic enumeration of permutations of a set of n objects
- Two recursive algorithms provide systematic ways to enumerate permutations
- Algorithm #1: remove one object and insert it into every possible position
- Base case: when n = 1, the object itself is the only permutation
- Recursive step: find the permutations of the remaining n − 1 objects, then insert the removed object at every position
- Example: generate RISK permutations from ISK permutations, then generate BRISK permutations from RISK permutations
- Algorithm #2: prepend each object to the permutations of all the other objects
- Recursive step: remove each object in turn and prepend it to the permutations of the remaining objects
- The two algorithms achieve the same goal but produce permutations in a different order
- The choice between the two algorithms is a matter of personal preference
- BRISK has 120 permutations
