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
Feed/

How can permutations be systematically enumerated?

Channel

Brisk

1 page

"We’ve discovered that there are 120 permutations of BRISK, but how would we go about listing them all? You can play around with the Davies kids and stumble upon all 6 permutations, but for larger numbers it’s harder. We need a systematic way. Two of the easiest ways to enumerate permutations involve recursion.\n\nAlgorithm #1 for enumerating permutations\n\n1. Begin with a set of n objects.\n\na) If n = 1, there is only one permutation; namely, the object itself.\n\nb) Otherwise, remove one of the objects, and find the permutations of the remaining n − 1 objects. Then, insert the removed object at every possible position, creating another permutation each time.\n\nAs always with recursion, solving a bigger problem depends on solving smaller problems. Let’s start with RISK. We’ve already discovered from the toothbrushing example that the permutations of ISK are ISK, IKS, SIK, SKI, KIS, and KSI. So to find the permutations of RISK, we insert an R into each possible location for each of these ISK-permutations. Once we have the RISK permutations, we can generate the BRISK permutations in the same way.\n\nAnother algorithm to achieve the same goal (though in a different order) is as follows:\n\nAlgorithm #2 for enumerating permutations\n\n1. Begin with a set of n objects.\n\na) If n = 1, there is only one permutation; namely, the object itself.\n\nb) Otherwise, remove each of the objects in turn, and prepend that object to the permutations of all the others, creating another permutation each time.\n\nI find this one a little easier to get my head around, but in the end it’s personal preference. The permutations of BRISK are: “B followed by all the permutations of RISK, plus R followed by all the permutations of BISK, plus I followed by all the permutations of BRSK, etc.”"

Flowchart preview
Series cover
👍
0
0 comments0 shares

Sign in to view and post comments.