5 Generating Permutations and Combinations
Let \(b_1, b_2, \dots , b_n\) be a sequence of integers satisfying
Then there exists a unique permutation of \(\{ 1, 2, \dots , n\} \) whose inversion sequence is \(b_1, b_2, \dots , b_n\).
The preceding algorithm for generating the \(n\)-tuples of 0s and 1s produces the reflected Gray code of order \(n\) for each positive integer \(n\).
Let \(a_1, a_2 \cdots a_r\) be an \(r\)-subset of \(\{ 1, 2, \dots , n\} \). The first \(r\)-subset in the lexicographic ordering is \(1 2 \cdots r\). The last \(r\)-subset in the lexicographic ordering is \((n-r+1)(n-r+2) \cdots n\). Assume that \(a_1a_2 \cdots a_r \neq (n-r+1)(n-r+2) \cdots n\). Let \(k\) be the largest integer such that \(a_k {\lt} n\) and \(a_k + 1\) is different from each of \(a_{k+1}, \dots , a_r\). Then the \(r\)-subset that is the immediate successor of \(a_1a_2 \cdots a_r\) in the lexicographic ordering is
The \(r\)-subset \(a_1a_2 \cdots a_r\) of \(\{ 1, 2, \dots , n\} \) occurs in place number
in the lexicographic order of the \(r\)-subsets of \(\{ 1, 2, \dots , n\} \).
Let \(X\) be a finite set with \(n\) elements. Then there is a one-to-one correspondence between the total orders on \(X\) and the permutations of \(X\). In particular, the number of different total orders on \(X\) is \(n!\).
Let \((X, \leq )\) be a finite partially ordered set. Then there is a linear extension of \((X, \leq )\).
Let \(\sim \) be an equivalence relation on a set \(X\). Then the distinct equivalence classes partition \(X\) into nonempty parts. Conversely, given any partition of \(X\) into nonempty parts, there is an equivalence relation on \(X\) whose equivalence classes are the parts of the partition.