8Get Them All. Algorithms and Permutations.

DOI: 10.1201/9780429274107-8

8.1 Generating Permutations

8.1.1 Generating All n-Permutations

If we want to write a computer program to test a conjecture concerning permutations, we need to have an efficient method to generate all n-permutations for our machine. If the conjecture only concerns permutations with some restrictions, we can save a lot of time and effort by having a fast way to generate only those permutations with the required property.

One can certainly list all permutations lexicographically. That is, let us define a partial order on the set of all n-permutations as follows. Let p=p1p2pn<q1q2qn if for the smallest index i for which piqi, we have pi<qi. The total order defined on ...

Get Combinatorics of Permutations, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.