Concept

How can permutations be systematically enumerated?

Stephen Davies, Ph.D. Version 2.2.2 Through Discrete Mathematics A Cool Brisk Walk / Chapter 1

"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.”"

Related Ideas

How can permutations be systematically enumerated? | Stephen Davies, Ph.D. Version 2.2.2 Through Discrete Mathematics A Cool Brisk Walk | Bifalgorithm | Bifalgorithm