# Combinatorial Enumeration: Theory and Practice · PDF file Combinatorial Enumeration: Theory and Practice Gordon Royle Semester 1, 2004 Gordon Royle Combinatorial Enumeration: Theory

• View
29

0

Embed Size (px)

### Text of Combinatorial Enumeration: Theory and Practice · PDF file Combinatorial Enumeration: Theory...

• Subsets Permutations

Combinatorial Enumeration: Theory and Practice

Gordon Royle

Semester 1, 2004

Gordon Royle Combinatorial Enumeration: Theory and Practice

• Subsets Permutations

Counting Generating Ranking

k-subsets

For many applications we wish to only consider subsets of a fixed size — the k-subsets of an n-set.

There are two common orderings used to list k-subsets, shown here for 2-subsets of a 5-set.

I Lexicographic

12, 13, 14, 15, 23, 24, 25, 34, 35, 45

I Co-lexicographic

12, 13, 23, 14, 24, 34, 15, 25, 35, 45

Note: Here we are using 12 as shorthand for {1, 2}.

Gordon Royle Combinatorial Enumeration: Theory and Practice

• Subsets Permutations

Counting Generating Ranking

Enumeration

Theorem The number of k-subsets of an n-set is given by the binomial coefficient (

n

k

) =

n! k!(n− k)!

.

Proof. The number of sequences of k distinct elements from an n-set is

n(n− 1)(n− 2) · · · (n− k + 1).

Every k-subset will occur in k! different orders in this list of sequences, and so the total number of k-subsets is

n(n− 1)(n− 2) · · · (n− k + 1) k!

.

Gordon Royle Combinatorial Enumeration: Theory and Practice

• Subsets Permutations

Counting Generating Ranking

Binomial Identities

A significant area of “classical” combinatorics is the discovery and proof of the many binomial identities relating appropriate binomial coefficients.

For example, ( n

k − 1

) +

( n

k

) =

( n + 1

k

)

Many of these identities can be proved in two ways - an algebraic proof or a combinatorial proof.

Gordon Royle Combinatorial Enumeration: Theory and Practice

• Subsets Permutations

Counting Generating Ranking

Algebraic Proofs

Algebraic proofs simply involve manipulation of the formulas to get the stated identity. (

n

k − 1

) +

( n

k

) =

n! (n− (k − 1))!(k − 1)!

+ n!

(n− k)!k!

= kn! + (n + 1− k)n!

(n + 1− k)!k!

= (

n + 1 k

)

Gordon Royle Combinatorial Enumeration: Theory and Practice

• Subsets Permutations

Counting Generating Ranking

Combinatorial Proofs

A combinatorial proof aims to explain the identity, rather than simply verify it.

Suppose there are n + 1 objects, one of which is “distinguished” from the others. Any k-subset of this set either

I contains the distinguished object, or

I doesn’t contain the distinguished object.

There are (

n k−1

) sets in the first category and

( n k

) in the second

category and so the stated identity holds.

A combinatorial proof is usually viewed as conveying more information than an algebraic proof, but there are many situations where only an algebraic proof is known.

Gordon Royle Combinatorial Enumeration: Theory and Practice

• Subsets Permutations

Counting Generating Ranking

Exercise

Find a combinatorial proof of the following identity:

n∑ k=0

( n

k

)2 =

( 2n n

) Hint: Consider the 2n objects as consisting of two groups of n objects.

Gordon Royle Combinatorial Enumeration: Theory and Practice

• Subsets Permutations

Counting Generating Ranking

The odometer principle

Lexicographic order is related to the “odometer” principle used in a car odometer: increase the least significant digit if possible, and otherwise roll that digit over to 0 and increase the next least significant digit.

1 4 3 2 2 1 4 3 2 3

2 3 7 9 9 2 3 8 0 0

Gordon Royle Combinatorial Enumeration: Theory and Practice

• Subsets Permutations

Counting Generating Ranking

Representing a k-set

We will represent a k-set T by a sequence (or array) listing its elements in increasing order

t1 < t2 < . . . < tk,

which we can view as a sort of k-digit odometer

t1 t2 · · · tk

with strange properties.

Gordon Royle Combinatorial Enumeration: Theory and Practice

• Subsets Permutations

Counting Generating Ranking

Example: 3-subsets of a 7-set

This “odometer” starts at the smallest possible value

1 2 3

because no digits can be repeated.

Using the odometer principle is easy for the first few successors:

1 2 4 1 2 5 1 2 6 1 2 7

Gordon Royle Combinatorial Enumeration: Theory and Practice

• Subsets Permutations

Counting Generating Ranking

Successor of {1, 2, 7}

We cannot increase the last position any more, so we

I propagate the increase one position to the left, and

I put the lowest possible value in the last position.

1 2 7 1 3 4

If the next position over is already in its highest possible position, then the increase must be propagated further to the left:

1 6 7 2 3 4

Gordon Royle Combinatorial Enumeration: Theory and Practice

• Subsets Permutations

Counting Generating Ranking

In GAP

nextLex := function(T,n,k) local S,pos,i; pos := k; while (pos > 0) and (T[pos] = n+pos-k) do pos := pos-1;

od; if (pos = 0) then S := [1..k];

else S := T; S[pos] := S[pos]+1; for i in [pos+1..k] do S[i] := S[i-1]+1;

od; fi; return S;

end;

Gordon Royle Combinatorial Enumeration: Theory and Practice

• Subsets Permutations

Counting Generating Ranking

Ranking A ranking function is much less pleasant to calculate for this ordering — for example, consider finding the rank of {2, 5, 7} in the ordering of 3-subsets of a 7-set. This equivalent to finding the number of sets that occur before {2, 5, 7} in the ordering, which are the sets of the form:

1 ? ? 2 3 ? 2 4 ? 2 5 6

The key to counting these is to observe that the number of each type is just a binomial coefficient, and in fact we have(

6 2

) +

( 4 1

) +

( 3 1

) + 1 = 23.

Gordon Royle Combinatorial Enumeration: Theory and Practice

• Subsets Permutations

Counting Generating Ranking

Ranking (cont.)

The number of subsets before

t1 t2 · · · tk

is the sum of the numbers of subsets that

I · · · I Start with t1t2 · · · tk−1uk where uk < tk.

Gordon Royle Combinatorial Enumeration: Theory and Practice

• Subsets Permutations

Counting Generating Ranking

Ranking (cont.)

The number of subsets whose i lowest values are

t1 t2 . . . ti

is ( n− ti k − i

) because the remaining positions determine a k − i subset chosen from a set of size n− ti.

Gordon Royle Combinatorial Enumeration: Theory and Practice

• Subsets Permutations

Counting Generating Ranking

Ranking (cont.)

So, the number of subsets that start with u1, where u1 < t1 is

t1−1∑ j=1

( n− j k − 1

) with the index j running over all the feasible values for u1. Similarly the number of subsets that start with t1u2 is

t2−1∑ j=t1+1

( n− j k − 2

) again with the index j running over all possible values for u2 (notice that the lowest possible value for u2 is t1 + 1).

Gordon Royle Combinatorial Enumeration: Theory and Practice

• Subsets Permutations

Counting Generating Ranking

The final expression

The rank of the subset {t1, t2, . . . , tk} is

k∑ i=1

 ti−1∑ j=ti−1+1

( n− j k − i

) where t0 = 0.

(This is the kind of equation that you derive once, then program in a reusable manner and hope you never have to derive again!)

Gordon Royle Combinatorial Enumeration: Theory and Practice

• Subsets Permutations

Counting Generating Ranking

Colexicographic order

The other ordering on k-sets that is common is called colexicographic order. To determine this order, we represent a k-set by a sequence t1, t2, . . ., tk with the property that

t1 > t2 > · · · > tk.

Set Representative Set Representative

{1, 2, 3} 321 {1, 2, 4} 421 {1, 2, 5} 521 {1, 3, 4} 431 {1, 3, 5} 531 {1, 4, 5} 541 {2, 3, 4} 432 {2, 3, 5} 532 {2, 4, 5} 542 {3, 4, 5} 543

Gordon Royle Combinatorial Enumeration: Theory and Practice

• Subsets Permutations

Counting Generating Ranking

Colexicographic order (cont)

Colexicographic (colex) order is then defined by listing these representatives in normal lexicographic order:

321, 421, 431, 432, 521, 531, 532, 541, 542, 543

One of the important properties of colex order is that the ordering does not depend on n. More precisely, the colex ordering for the k-subsets of an n-set is the leading portion of the colex ordering for the k-subsets of an (n + 1)-set.

Gordon Royle Combinatorial Enumeration: Theory and Practice

• Subsets Permutations

Counting Ge

Documents
Documents
Documents
Documents
Documents
Documents
Documents
Documents
Documents
Documents
Documents
Documents
Documents
Documents
Documents
Documents
Documents
Education
Documents
Documents
Documents
Documents
Documents
Documents
Documents
Documents
Documents
Documents
Documents
Documents