Handout Combinatorics
Handout Combinatorics
General notations
The set of natural numbers is denoted by N, i.e., N = {0, 1, 2, 3, 4, 5, . . .}. (There is still an
ongoing dicussion whether 0 is a natural number or not. In this course we will assume that
0 is a natural number.) The set of the first n positive natural numbers, with n ∈ N and
n > 0, is denoted by Nn , i.e., Nn = {1, 2, . . . , n}. The set of integer numbers is denoted
by Z, i.e., Z = {. . . , −3, −2, −1, 0, 1, 2, 3, . . .}. The set of real numbers is denoted by R.
The set of non-negative real numbers is denoted by R≥0 , i.e., R≥0 = {x ∈ R : x ≥ 0}.
Similarly, the set of positive real numbers is denoted by R>0 , i.e., R>0 = {x ∈ R : x > 0}.
Alternative notations for R≥0 and R>0 are R+ and R++ , respectively.
The factorial of a natural number n ∈ N is denoted by n!, i.e., n! = n · (n − 1) · . . . · 1.
Note that by convention 0! = 1.
Preliminaries on sets
The difference of two sets A and B is defined as
A \ B = {x ∈ A : x ∈
/ B}.
Example 1 (set difference). Consider the sets N6 = {1, 2, 3, 4, 5, 6} and A = {1, 2, 3, 5},
then N6 \ A = {4, 6}. If we define B = {2, 5}, then A \ B = {1, 3}. Moreover, if we define
C = {3, 4}, then A \ C = {1, 2, 5}. 4
The Cartesian product of two sets A and B, denoted by A × B, is defined as the set
consisting of all ordered pairs (a, b) with a ∈ A and b ∈ B, i.e.,
Example 2. (Cartesian product) The standard deck of 52 cards can be written as the
Cartesian product of the sets A and B, where A = {♥, ♠, ♦, ♣} is the set of card suits
and B = {Ace, 2, 3, . . . , 9, 10, Jack, Queen, King} is the set of card ranks. Hence,
A × B = {(♥, Ace), (♥, 2), (♥, 3), ..., (♣, 9), (♣, 10), (♣, Jack), (♣, Queen), (♣, King)}. 4
Preliminaries on functions
A function f : A → B is defined by
• the domain A,
1
• the codomain B, and
• the relation f .
The set of all images is called the range of f on A and is denoted by Rf , i.e.,
Rf = {f (a) : a ∈ A}.
• X = {a, b, c, . . . , x, y, z},
• Y = N,
maps each character to its position in the alphabet. However, note that the function
g : X → Z, defined by
• X = {a, b, c, . . . , x, y, z},
2
Ace 2 3 4 5 6 7 8 9 10 Jack Queen King
♥ 1 2 3 4 5 6 7 8 9 10 11 12 13
• ♠ 27 28 29 30 31 32 33 34 35 36 37 38 39
♦ 14 15 16 17 18 19 20 21 22 23 24 25 26
♣ 52 51 50 49 48 47 46 45 44 43 42 41 40
is injective. 4
• Y = {1, 2, 3, 4},
is surjective (because the codmain and range coincide, i.e., Rf = {1, 2, 3, 4} = Y ) but not
injective. 4
3
Figure 3: A bijective function
Hence, an inverse function is a function that “reverses” another function. Figure 4 illus-
trates the inverse function of the bijection in Figure 3.
Example 7 (inverse function). The inverse function of the bijective function g from
Example 3 is the function g −1 : Z → X defined by
• Z = {1, 2, 3, . . . , 24, 25, 26},
4
• X = {a, b, c, . . . , x, y, z},
Note that it is not difficult to see that g(g −1 (z)) = z for all z ∈ Z and g −1 (g(x)) = x for
all x ∈ X, so g −1 is indeed the inverse function of g. 4
What is combinatorics?
Combinatorics is an area of mathematics primarily concerned with counting. Counting is
determining the number of elements in a set. The number of elements in a set A equals
the number of ways to choose an element x ∈ A. The number of elements in a set A is
called the cardinality of A and is denoted by |A|.
Four fundamental rules in combinatorics are:
• Rule of sum: If A and B are finite, disjoint sets, then |A ∪ B| = |A| + |B|.
• Rule of difference: If A and B are finite sets and B ⊆ A, then |A \ B| = |A| − |B|.
• One-to-one rule: Let A and B be finite sets. The number of elements in A and B
is equal (|A| = |B|) if and only if there is a one-to-one correspondence between A
and B.
• General rule of sum: If A1 , A2 , . . . , Ak are finite and pairwise disjoint sets, then
|A1 ∪ A2 ∪ . . . ∪ Ak | = |A1 | + |A2 | + . . . + |Ak |.
Example 8 (Rule of sum (source: Wikipedia)). A woman has decided to shop at one store
today, either in the north part of town or the south part of town. If she visits the north
part of town, she will shop at either a mall, a furniture store, or a jewelry store (3 ways).
If she visits the south part of town then she will shop at either a clothing store or a shoe
store (2 ways). If we denote A = {mall, furniture, jewelry} and B = {clothing, shoe},
then, using to the rule of sum, there are
|A ∪ B| = |A| + |B| = 3 + 2 = 5
Example 9 (Rule of product (source: Wikipedia)). When you decide to order pizza,
you must first choose the type of crust: thin crust or deep dish (2 choices). Next,
you choose one topping: cheese, pepperoni, or sausage (3 choices). If we denote A =
{thin crust, deep dish} and B = {cheese, pepperoni, sausage}, then, using the rule of
product, there are
|A × B| = |A| · |B| = 2 · 3 = 6
possible combinations of ordering a pizza. 4
5
Example 10 (One-to-one rule). Reconsider Example 3 and 7. Since we showed that
there is a one-to-one correspondence between the X = {a, b, c, . . . , x, y, z} and Z =
{1, 2, 3, . . . , 24, 25, 26}, we have formally proven that |X| = |Z|. 4
Let X be a finite set. We define the power set of X as the set containing all subsets
of X, i.e.,
P(X) = {A : A ⊆ X}.
Furthermore, for k ≥ 0, we define
6212 = 3, 226, 266, 762, 397, 899, 821, 056 ≈ 3.3 · 1021 4
6
Theorem 1. Selecting a k-permutation from n elements, with repetition, can be done in
nk ways.
Proof. Use in the general rule of product for every set Ai , with i ∈ {1, . . . , k}, the set with
n elements. Then, it immediately follows from the general rule of product that selecting
a k-permutation from n elements, with repetition, can be done in nk ways.
k-permutation from n
Example 13. In order to organize a student party a committee is needed consisting of a
chairman, a treasurer and a secretary. Note the following two important observations:
- Order is important: Alice is chairman, Bob is treasurer and Carol is secretary 6= Bob
is chairman, Alice is treasurer and Carol is secretary.
If there are 10 candidates, then for choosing the chairman, we can choose from 10 students.
Note that a student cannot be both a chairman and treasurer and thus the chairman
cannot be chosen as a treasurer anymore. Therefore, for choosing the treasurer, we can
choose from 9 students. Similarly, for choosing the secretary, we can choose from 8
students. Hence, the number of different committees that can be formed equals
10!
10 · 9 · 8 = = 720 4
(10 − 3)!
k-combination from n
Example 14. Texas Hold’em is played with a standard deck containing 52 cards. Every
player gets two cards from the deck and then the game starts. Note the following two
important observations:
- Repetition is not allowed: You cannot have {(♠, Ace), (♠, Ace)}.
- Order is not important: {(♦, 4), (♣, Jack)} = {(♣, Jack), (♦, 4)}.
7
The number of different hands equals
52 52!
= = 1326 4
2 2!(52 − 2)!
Note that the following three problems are equivalent with a k-combination from n:
1. Selecting k elements from a set with n elements without repetition and without
order.
Theorem
3. Selecting a k-combination from n elements, without repetition, can be done
n n!
in = ways.
k k!(n − k)!
Proof. The proof will be given in the lecture and can be found in the lecture slides.
n n
The numbers are called binomial coefficients. We pronounce as ‘n
k k
choose k’.
The number of different ways that the grandmother can distribute the chocolates over her
grandchildren equals
10 + 20 − 1 10 + 20 − 1
= = 10015005. 4
20 20!(10 − 1)!
Theorem
4.Selecting a k-combination from n elements, with repetition, can be done in
n+k−1 (n + k − 1)!
= ways.
k k!(n − 1)!
Proof. Two different proofs will be given in the lecture and can be found in the lecture
slides.
8
Example 16. Consider words of 10 characters with 3 zeroes, 3 ones, and 4 twos. For
example, 0221021102 is such a word and it is called a 10-permutation from 3 elements,
with repetition of type 3, 3, 4. The number of different words equals
10 10!
= = 4200. 4
3, 3, 4 3! · 3! · 4!
Theorem 5. Selecting
a k-permutation
from n elements, with repetition of type t1 , t2 , . . . , tn ,
k k!
can be done in = ways.
t1 , t2 , . . . , tn t1 ! · t2 ! · · · tn !
Proof. The proof will be given in the lecture and can be found in the lecture slides.
k
The numbers are called multinomial coefficients and are a general-
t1 , t2 , . . . , tn
ization of the binomial coefficients.
9
In this picture we have A ∩ B ∩ C = ∅ and F ⊆ E ⊆ D. (Note that making such a picture
is not mandatory, but it might help you quite a lot with writing the combinatorial proof.)
Step 1: Define the set X as follows
Note that any element (A, B, C) ∈ X can be obtained by first selecting a subset A, then
to choose r − i elements
a subset B, and finally a subset C. For the subsetA, we have
n
among the n elements in Nn . This can be done in ways. Given A, we have to
r−i
select s − i elements among then − (r − i)
= n − r + i elements in Nn \ A to form the
n−r+i
subset B. This can be done in ways. Given A and B, we have to select i
s−i
elements amongthe n − (r − i) −(s − i) = n − r − s + 2i elements in (Nn \ A) \ B. This
n − r − s + 2i
can be done in ways. This shows that
i
n n−r+i n − r − s + 2i
|X| = .
r−i s−i i
Note that any element (D, E, F ) ∈ Y can be obtained by first selecting a subset D, then
a subset E, and finally a subset F . For the subset choose r + s − i elements
D, we have to
n
among the n elements in Nn . This can be done in ways. Given D, we have
r+s−i
to selects elements among
the r + s − i elements in D to form the subset E. This can be
r+s−i
done in ways. Given E, we have to select i elements among the r + s − i
s
r+s−i
elements in E. This can be done in ways. This shows that
i
n r+s−i s
|Y | = .
r+s−i s i
f −1 : Y → X with f −1 ((D, E, F )) = (D \ E, E \ F, F ).
In order to show that f −1 is indeed the inverse function of f , one needs to verify that
10
For this, let (A, B, C) ∈ X. Then,
Hence, f −1 is indeed the inverse function of f . Therefore, by the one-to-one rule, it holds
that |X| = |Y | and thus also
n n−r+i n − r − s + 2i n r+s−i s
= .
r−i s−i i r+s−i s i
4
Note that any element (A, B, x) ∈ Xi can be obtained by first selecting A ⊆ Nn , then
B ⊆ A, and finally x ∈ B. For A ⊆Nn with |A| = i we choose i elements from a set with
n
n elements. This can be done in ways. For B ⊆ A with |B| = m we choose m
i
i
elements from the set A with i elements. This can be done in ways. Finally, we
m
choose x ∈ B. This can be done in m ways. It follows that
n i
|Xi | = m.
i m
11
Step 2: Define the set Y as follows
Note that any element (y, C, D) ∈ Y can be obtained by first selecting y ∈ Nn , then
C ⊆ Nn \ {y}, and finally D ⊆ (Nn \ {y}) \ C. For y ∈ Nn there are n options. For C we
choose
m − 1 elements from a set with |Nn \ {y}| = n − 1 elements. This can be done in
n−1
ways. Finally, we choose a subset D of a set with |(Nn \ {y}) \ C| = n − m
m−1
elements. This can be done in 2n−m ways. It follows that
n−1
|Y | = n 2n−m .
m−1
In order to show that f −1 is indeed the inverse function of f , one needs to verify that
Hence, f −1 is indeed the inverse function of f . Therefore, by the one-to-one rule, it holds
that |Xm ∪ . . . ∪ Xn | = |Y | and thus also
n
X n i n−1
m=n 2n−m . 4
i m m−1
i=m
12
Some famous combinatorial theorems
Below you can find some famous combinatorial theorems. The combinatorial proofs of
these theorems will be given in the lecture and can be found in the lecture slides. Note
that those theorems can also be proved ‘by formulas’. However, in this course we will
only focus on the corresponding combinatorial proofs.
Moreover, since
n Xn n
n
[
Sum rule
X
= |P(Nn , k)| = P(Nn , k) = |P(Nn )| ,
k
k=0 k=0 k=0
we have |P(Nn )| = 2n . This means that it follows from Newton’s binomial theorem that
the number of subsets of Nn equals 2n . Similarly, if we set x = −1 and y = 1 in the
binomial theorem, then
n n
n
X n n k n−k
X
k n
0 = 0 = (−1 + 1) = (−1) 1 = (−1) .
k k
k=0 k=0
This means that it follows from Newton’s binomial theorem that there are as many subsets
of Nn of even size as subsets of Nn of odd size.
13