In mathematics, and in particular in combinatorics, the combinatorial number system of degree k (for some positive integer k), also referred to as combinadics, or the Macaulay representation of an integer, is a correspondence between natural numbers (taken to include 0) N and k-combinations. The combinations are represented as strictly decreasing sequences ck > ... > c2 > c1 ≥ 0 where each ci corresponds to the index of a chosen element in a given k-combination. Distinct numbers correspond to distinct k-combinations, and produce them in lexicographic order. The numbers less than
\tbinomnk
The number N corresponding to (ck, ..., c2, c1) is given by
N=\binom{ck}k+ … +\binom{c2}2+\binom{c1}1
The fact that a unique sequence corresponds to any non-negative number N was first observed by D. H. Lehmer.[1] Indeed, a greedy algorithm finds the k-combination corresponding to N: take ck maximal with
\tbinom{ck}k\leqN
\tbinom{ck-1
The originally used term "combinatorial representation of integers" was shortened to "combinatorial number system" by Knuth,[4] who also gives a much older reference;the term "combinadic" is introduced by James McCaffrey (without reference to previous terminology or work).
Unlike the factorial number system, the combinatorial number system of degree k is not a mixed radix system: the part
\tbinom{ci}i
The main application of the combinatorial number system is that it allows rapid computation of the k-combination that is at a given position in the lexicographic ordering, without having to explicitly list the preceding it; this allows for instance random generation of k-combinations of a given set. Enumeration of k-combinations has many applications, among which are software testing, sampling, quality control, and the analysis of lottery games.
A k-combination of a set S is a subset of S with k (distinct) elements. The main purpose of the combinatorial number system is to provide a representation, each by a single number, of all
\tbinomnk
In order to ensure that the numbers representing the k-combinations of are less than those representing k-combinations not contained in, the k-combinations must be ordered in such a way that their largest elements are compared first. The most natural ordering that has this property is lexicographic ordering of the decreasing sequence of their elements. So comparing the 5-combinations C = and C′ = , one has that C comes before C′, since they have the same largest part 9, but the next largest part 6 of C is less than the next largest part 7 of C′; the sequences compared lexicographically are (9,6,4,3,0) and (9,7,3,1,0).
Another way to describe this ordering is view combinations as describing the k raised bits in the binary representation of a number, so that C = describes the number
c1 | |
2 |
c2 | |
+2 |
ck | |
+ … +2 |
The number associated in the combinatorial number system of degree k to a k-combination C is the number of k-combinations strictly less than C in the given ordering. This number can be computed from C = with ck > ... > c2 > c1 as follows.
From the definition of the ordering it follows that for each k-combination S strictly less than C, there is a unique index i such that ci is absent from S, while ck, ..., ci+1 are present in S, and no other value larger than ci is. One can therefore group those S according to the possible values 1, 2, ..., k of i, and count each group separately. For a given value of i one must includeck, ..., ci+1 in S, and the remaining i elements of S must be chosen from the ci non-negative integers strictly less than ci; moreover any such choice will result in a S strictly less than C. The number of possible choices is
\tbinom{ci}i
\binom{c1}1+\binom{c2}2+ … +\binom{ck}k,
Obviously there is for every N ∈ N exactly one k-combination at index N in the list (supposing k ≥ 1, since the list is then infinite), so the above argument proves that every N can be written in exactly one way as a sum of k binomial coefficients of the given form.
The given formula allows finding the place in the lexicographic ordering of a given k-combination immediately. The reverse process of finding the k-combination at a given place N requires somewhat more work, but is straightforward nonetheless. By the definition of the lexicographic ordering, two k-combinations that differ in their largest element ck will be ordered according to the comparison of those largest elements, from which it follows that all combinations with a fixed value of their largest element are contiguous in the list. Moreover the smallest combination with ck as the largest element is
\tbinom{ck}k
\tbinom{ck}k
\tbinom{ck}k\leqN
N-\tbinom{ck}k
N-\tbinom{ck}k
Suppose one wants to determine the 5-combination at position 72. The successive values of
\tbinomn5
\tbinomn4
72=\tbinom85+\tbinom64+\tbinom33
\tbinom{ci}i=0
For each of the
\binom{49}6
\binom{49}6-1
\binom{49-c1}6+\binom{49-c2}5+\binom{49-c3}4+\binom{49-c4}3+\binom{49-c5}2+\binom{49-c6}1.