General Counting Methods in Combinatorics
General Counting Methods in Combinatorics
1
Course topics
0. Introduction 6. Graphs
4. Generating functions
5. Recurrence relations
3
Outline
1. Simple arrangements and selections
3. Distributions
4. Binomial identities
4
Simple arrangements and selections
5
Simple arrangements and selections
6
Simple arrangements and selections
𝑛
We use 𝑃 𝑛, 𝑟 , 𝐶 𝑛, 𝑟 ≔ 𝐶𝑛𝑟 : = to denote the number of 𝑟 -
𝑟
permutations and 𝑟-combinations, respectively, of a set of 𝑛 objects.
7
Simple arrangements and selections
and
𝑛!
𝑃 𝑛, 𝑟 = 𝑛 𝑛 − 1 𝑛 − 2 … 𝑛 − 𝑟 − 1 =
𝑛−𝑟 !
8
Simple arrangements and selections
𝑛 𝑃(𝑛, 𝑟) 𝑛!/ 𝑛 − 𝑟 ! 𝑛!
= 𝐶 𝑛, 𝑟 = = =
𝑟 𝑃(𝑟, 𝑟) 𝑟! 𝑟! 𝑛 − 𝑟 !
9
Example 12: Ranking Wizards
10
Example 12: Ranking Wizards
11
Example 12: Ranking Wizards
Solution. We need to find the probability that the fifth candidate, Gandalf, is ranked
in the second position when the ranking is made at random (each ranking is equally
likely):
12
Example 12: Ranking Wizards
𝑛−1 ! 1
Prob(Gandalf second) = = .
𝑛! 𝑛
13
Example 13: Arrangements with Repeated Letters
How many ways are there to arrange the seven letters in the word
SYSTEMS? In how many of these arrangements do the three Ss
appear consecutively?
14
Example 13: Arrangements with Repeated Letters
15
Example 13: Arrangements with Repeated Letters
To find the number of arrangements where the three S’s appear consecutively, we
can treat the three S’s as a single "super letter" or block. The word "SYSTEMS"
now consists of:
- 1 block of [SSS]
So, the problem reduces to arranging the five distinct letters, Y, T, E, M and SSS
(treated as a single letter), which can be done in 5! = 120 ways.
16
Example 14: Poker Probabilities
17
Example 14: Poker Probabilities
a) A 5-card hand is a subset of five cards chosen from the 52 cards in a deck, and
so there are:
52!
𝐶 52, 5 = = 2,598,960.
47! 5!
18
Example 14: Poker Probabilities
5148
Prob 5 − card hand is a flush = = 0.00198
2,598,960
19
Example 14: Poker Probabilities
c) To count the number of hands with exactly three Aces, we must pick three of the
four Aces – done in 𝐶 4,3 = 4 ways – and then fill out the hand with two card
chosen from the 48 non-Ace cards – done in 𝐶 48,2 = 1128 ways. So, there
are 4 × 1128 = 4512 hands with exactly three Aces. Finally, we get:
4512
Prob 5 − card hand has exactly three Aces = = 0.00174.
2,598,960
20
The Set Composition Principle
21
Example 13 (continued): Arrangements with Repetitions
22
Example 13 (continued): Arrangements with Repetitions
23
Example 13 (continued): Arrangements with Repetitions
24
Example 15: Counting Defective Products
25
Example 15: Counting Defective Products
Solution. The sequence has 15 positions, and each position can be either A
or U. Without any constraints, the total number of possible sequences would
be 215 since there are 2 choices (A or U) for each of the 15 positions.
- If the third U appears at the twelfth letter in the sequence, then the
subsequence composed of the first 11 letters must have exactly two Us
(and nine As). So there are 𝐶 11, 2 = 55 possible sequences for the
first 11 letters.
26
Example 15: Counting Defective Products
27
Example 16: Probability of Repeated Digits
Hint. There are 104 = 10,000 different 4-digit phone numbers, so we break the
problem into four different cases of repetitions:
a) All four digits are the same.
b) three digits are the same, the other is different.
c) two digits are the same, the other two digits are also the same (e.g., 2828).
d) two digits are the same, the other two digits are each different (e.g., 5105).
28
Outline
1. Simple arrangements and selections
3. Distributions
4. Binomial identities
29
Example 17: Arrangements of banana
How many arrangements are there of the six letters b, a, n, a, n, a?
n a b n a a
30
Example 17: Arrangements of banana
How many arrangements are there of the six letters b, a, n, a, n, a?
n a b n a a
⇒ The key is to focus on the subset of positions where the as go and the
subset of positions where the ns go.
31
Example 17: Arrangements of banana
1 2 3 4 5 6
Solution.
6
- First choosing the subset of 3 positions in the arrangement where the as will go: = 20 ways.
3
3
- Then the subset of two positions (out of the remaining three) where the ns will go: = 3 ways.
2
1
- Finally, the last remaining position gets the b: = 1 way
1
6 3 1
Thus, we have: × × = 20 × 3 × 1 = 60 ways.
3 2 1
32
Example 17: Arrangements of banana
1 2 3 4 5 6
Solution.
6!
= 60
3! 2! 1!
33
Theorem 1. If there are 𝑛 objects, with 𝑟1 of type 1, 𝑟2 of type 2, …, and
𝑟𝑚 of type 𝑚, where 𝑟1 + 𝑟2 + ⋯ + 𝑟𝑚 = 𝑛, then the number of
arrangements of these 𝑛 objects, denoted as 𝑃 𝑛; 𝑟1 , 𝑟2 , … , 𝑟𝑚 is
𝑛 𝑛 − 𝑟1 𝑛 − 𝑟1 − 𝑟2 − ⋯ 𝑟𝑚−1 𝑛!
𝑃 𝑛; 𝑟1 , 𝑟2 , … , 𝑟𝑚 = 𝑟 𝑟2 … 𝑟𝑚 = .
1 𝑟1 ! 𝑟2 ! … 𝑟𝑚!
34
Example 18: Ordering Hot Dogs
How many different ways are there to select six hot dogs from three
varieties of hot dog?
35
Example 18: Ordering Hot Dogs
Solution. Suppose the three varieties are classic, cheese and veggie. Let a
selection be written down on an order form in the following fashion:
Each x represents a hot dog. The request shown on the form above is one classic,
four cheese, and one veggie. Since the hot dog chef knows that the sequence of
dogs on the form is classic, cheese and veggie, the request can simply be written
as xxxxx|x| without column headings.
36
Example 18: Ordering Hot Dogs
We observe that:
- Any selection of r hot dogs will consist of some sequence of 𝑟 xs and two |s.
37
Example 18: Ordering Hot Dogs
We observe that:
- Any selection of r hot dogs will consist of some sequence of 𝑟 xs and two |s.
8 2 8!
repetition problem whose answer is 𝑃 8; 6, 2 = = = 28
6 2 6!2!
38
Theorem 2. The number of selections with repetition of 𝑟 objects chosen from 𝑛
types of objects is:
𝑟+𝑛−1
.
𝑟
39
Example 19: Grouping Classes
Nine students, three from Ms. A’s class, three from Mr. B’s class, and three from
Ms. C’s class, have bought a block of nine seats for their school’s homecoming
game. If three seats are randomly selected for each class from the nine seats in a
row, what is the probability that the three A students, three B students, and three C
students will each get a block of three consecutive seats?
40
Example 19: Grouping Classes
Solution.
- The number of arrangements three As, three Bs, and three Cs in the row of nine
seats is: 𝑃 9; 3,3,3 = 9!Τ3! 3! 3! = 1680 ways.
- If the three students of each class are to sit together, then we want to count
outcomes that are arrangements of the three blocks, AAA, BBB, and CCC. Thus,
instead of nine letters, we really are working now with three composite letters.
There are 3! = 6 ways to arrange these three composite letters.
41
Example 20: Sequencing Genes (1/)
42
Example 20: Sequencing Genes (2/)
43
Example 20: Sequencing Genes (3/
44
Example 20: Sequencing Genes (4/)
• Since the fragment TATA does not end with a C, it must go at the end of the
string.
…..TATA
• The other seven fragments can occur in any order.
• These fragments consist of three Cs, two ACs, one AAATC, and one TGGC.
• Treat each fragment as a letter. Then we must arrange seven letters, three of
one type, two of a second type, and one each of two other types.
• There are 𝑃 7; 3, 2,1,1 = 420 possible arrangements of the fragments to form
a 20-letter string
45
Example 21: Sequences with Varying Repetitions
How many ways are there to form a sequence of 10 letters from four
as, four bs, four cs, and four ds if each letter must appear at least
twice?
46
Example 21: Sequences with Varying Repetitions
47
Example 21: Sequences with Varying Repetitions
- There are four cases for choosing which letter occurs four times.
- To arrange four of one letter and two of the three others, we have:
𝑃 10; 4,2,2,2 = 18,900 ways.
48
Example 21: Sequences with Varying Repetitions
- For choosing which two of the four letters occur three times:
𝐶 4,2 = 6 cases.
- To arrange three of two letters and two of the two others, we have:
𝑃 10; 3,3,2,2 = 25,200 ways.
49
Example 22: Selecting Doughnuts
How many ways are there to fill a box with a dozen doughnuts chosen
from five different varieties with the requirement that at least one
doughnut of each variety is picked?
50
Example 23: Selections with Lower and Upper Bounds
How many ways are there to pick a collection of exactly 10 balls from a
pile of red balls, blue balls, and purple balls if there must be at least
five red balls? If at most five red balls?
51
Example 24
• Trong quần thể có 𝑛 phần tử, có đúng 𝑠 phần tử dương tính. Biết rằng
mình có thể chọn ngẫu nhiên một số lượng phần tử trong quần thể. Sau
mỗi lần chọn thì bỏ những phần tử đã chọn vào lại quần thể. Tính số
lượng phần tử chọn tối thiểu và số lần chọn tối thiểu sao cho xác suất
chọn được một phần tử dương tính ít nhất là 1 − 𝜖, với 𝜖 > 0.
52
Example 24
• The result of each draw (the elements of the population being sampled)
can be classified into one of two mutually exclusive categories (e.g.
Pass/Fail or Employed/Unemployed).
53
A random variable
Example 24
A random variable X follows the hypergeometric distribution if its probability mass function is given by
𝐾 𝑁−𝐾
𝑝𝑋 𝑘 = Pr 𝑋 = 𝑘 = 𝑘 𝑛−𝑘
𝑁
𝑛
where
54
Outline
1. Simple arrangements and selections
3. Distributions
4. Binomial identities
55
Distributions
56
Distributions
57
Basic Models for Distributions
Distinct Objects. The process of distributing 𝑟 distinct objects into 𝑛 different boxes
is equivalent to putting the distinct objects in a row and stamping one of the 𝑛
different box names on each object. Thus, there are
𝑛 × 𝑛 × ⋯ × 𝑛 𝑟 𝑛𝑠 = 𝑛𝑟
distributions of the 𝑟 distinct objects.
58
Basic Models for Distributions
Distinct Objects. The process of distributing 𝑟 distinct objects into 𝑛 different boxes
is equivalent to putting the distinct objects in a row and stamping one of the 𝑛
different box names on each object. Thus, there are
𝑛 × 𝑛 × ⋯ × 𝑛 𝑟 𝑛𝑠 = 𝑛𝑟
distributions of the 𝑟 distinct objects.
6 distinct objects
6 6−3 6−3−1
= 𝑃(6; 3,1,2)
3 1 2
60
Basic Models for Distributions
𝑟+𝑛−1 𝑟+𝑛−1 !
=
𝑟 𝑟! 𝑛 − 1 !
𝑟 identical objects
Red Red Blue Blue Green Green Green 61
Basic Models for Distributions
7 = 2 + 2 + 3
62
Example 24: Assigning Diplomats
How many ways are there to assign 100 different diplomats to five
different continents? How many ways if 20 diplomats must be assigned
to each continent?
63
Example 24: Assigning Diplomats
How many ways are there to assign 100 different diplomats to five
different continents? How many ways if 20 diplomats must be assigned
to each continent?
64
Example 24: Assigning Diplomats
How many ways are there to assign 100 different diplomats to five
different continents? How many ways if 20 diplomats must be assigned
to each continent?
65
Example 25: Bridge Hands
66
Example 25: Bridge Hands
67
Example 25: Bridge Hands
Solution. So, the probability what West has all the spades is:
68
Example 25: Bridge Hands
69
Example 25: Bridge Hands
4
4! 𝑃 48; 12,12,12,12 4! 48! 52! 13! 4! 48! 4 ൗ 52
= 4
൘ 4
= 4
× = 13
𝑃(52; 13,13,13,13) 12! 13! 12! 52! 4
= 0.105
70
Example 26: Distributing Candy
71
Example 26: Distributing Candy
72
Example 27: Distributing Balls
73
Example 27: Distributing Balls
Solution.
𝑟−𝑛 +𝑛−1 !
𝐶 𝑟 − 𝑛 + 𝑛 − 1, 𝑟 − 𝑛 = = 𝐶(𝑟 − 1, 𝑛 − 1)
𝑟−𝑛 ! 𝑛−1 !
74
Example 27: Distributing Balls
Solution.
- First, for each 𝐼, put 𝑟𝑖 balls in the 𝑖-th box.
- There are now 𝑟 − 𝑟1 − 𝑟2 − ⋯ − 𝑟𝑛 balls left.
- Finally, count the ways to distribute without restriction the remaining 𝑟 −
𝑟1 − 𝑟2 − ⋯ − 𝑟𝑛 balls into the 𝑛 boxes.
- So this can be done in
𝐶( 𝑟 − 𝑟1 − 𝑟2 − ⋯ − 𝑟𝑛 + 𝑛 − 1, 𝑟 − 𝑟1 − 𝑟2 − ⋯ − 𝑟𝑛
= 𝐶( 𝑟 − 𝑟1 − 𝑟2 − ⋯ − 𝑟𝑛 + 𝑛 − 1, 𝑛 − 1)
75
Example 28: Integer Solutions
with:
a) 𝑥𝑖 ≥ 0?
b) 𝑥𝑖 ≥ 1?
c) 𝑥1 ≥ 2, 𝑥2 ≥ 2, 𝑥3 ≥ 4, 𝑥4 ≥ 0?
76
Example 28: Integer Solutions
Solution.
a) 𝑥𝑖 ≥ 0
An example of one solution is: 𝑥1 = 2, 𝑥2 = 3, 𝑥3 = 3, 𝑥4 = 4.
77
Example 28: Integer Solutions
b) 𝑥𝑖 ≥ 1?
There are: 𝐶 12 − 4 + 4 − 1 , 4 − 1 = 𝐶 8 + 4 − 1,4 − 1 = 165 ways.
c) 𝑥1 ≥ 2, 𝑥2 ≥ 2, 𝑥3 ≥ 4, 𝑥4 ≥ 0?
There are: 𝐶 12 − 2 + 2 + 4 + (4 − 1), 4 − 1 = 𝐶 4 + 4 − 1,4 − 1 = 35
ways.
78
Equivalent forms for selection with repetition
types of objects.
79
Example 28: Ingredients for a Witch’s Brew
80
Example 29: Binary Patterns
81
Summarization
3. Distributions
4. Binomial identities
83
Table of binomial coefficients
𝑛 𝑛!
= .
𝑘 𝑘! 𝑛 − 𝑘 !
- We’ll look at several patterns. First, the nonzero entries of each row
are symmetric; e.g., row 𝑛 = 4 is
4 4 4 4 4
, , , , = 1,4,6,4,1
0 1 2 3 4
𝑛 𝑛
which reads the same in reverse. Conjecture: = .
𝑘 𝑛−𝑘 84
Table of binomial coefficients
𝑛 𝑘=0 𝑘=1 𝑘=2 𝑘=3 𝑘=4 𝑘=5 𝑘=6
𝑘
𝑘 =0 1 0 0 0 0 0 0
𝑘 =1 1 1 0 0 0 0 0
𝑘 =2 1 2 1 0 0 0 0
𝑘 =3 1 3 3 1 0 0 0
𝑘 =4 1 4 6 4 1 0 0
𝑘 =5 1 5 10 10 5 1 0
𝑘 =6 1 6 15 20 15 6 1
85
A binomial coefficient identity
86
A binomial coefficient identity
Proof.
𝑛 𝑛! 𝑛! 𝑛
= = = .
𝑘 𝑘! 𝑛 − 𝑘 ! 𝑛 − 𝑘 ! 𝑘! 𝑛 − 𝑘
87
Table of binomial coefficients
𝑛 𝑘=0 𝑘=1 𝑘=2 𝑘=3 𝑘=4 𝑘=5 𝑘=6 Total
𝑘
𝑘 =0 1 0 0 0 0 0 0 1
𝑘 =1 1 1 0 0 0 0 0 2
𝑘 =2 1 2 1 0 0 0 0 4
𝑘 =3 1 3 3 1 0 0 0 8
𝑘 =4 1 4 6 4 1 0 0 16
𝑘 =5 1 5 10 10 5 1 0 32
𝑘 =6 1 6 15 20 15 6 1 64
88
Sum of binomial coefficients
𝑛
Theorem 4. For integers 𝑛 ≥ 0, we have: σ𝑛𝑘=0 = 2𝑛
𝑘
89
Sum of binomial coefficients
𝑛
Theorem 4. For integers 𝑛 ≥ 0, we have: σ𝑛𝑘=0 = 2𝑛
𝑘
90
Recursion for binomial coefficients
𝑛+1 𝑛 𝑛
= +
𝑘+1 𝑘 𝑘+1
92
Pascal’s triangle (Alternate way to present the table of binomial coefficients)
93
Pascal’s triangle (Alternate way to present the table of binomial coefficients)
94
Diagonal sums
95
Diagonal sums
• Yellow: 1 + 2 + 3 + 4 = 10
1 2 3 5 5
+ + + =
1 1 1 1 2
• Pink: 1 + 4 + 10 = 15
3 4 5 6
+ + =
3 3 3 4
96
Diagonal sums
We formal a pattern:
𝑘 𝑘+1 𝑘+2
+ +
𝑘 𝑘 𝑘
𝑛 𝑛+1
+ ⋯+ =
𝑘 𝑘+1
97
Diagonal sums
98
Diagonal sums
99
𝑛
Special cases of 1 + 𝑥
Theorem 7.
𝑛 𝑛 𝑛 𝑛 2 𝑛 𝑘 𝑛 𝑛
1+𝑥 = + 𝑥+ 𝑥 +⋯+ 𝑥 + ⋯+ 𝑥
0 1 2 𝑘 𝑛
𝑛 𝑛
𝑛 𝑘 𝑛−𝑘 𝑛 𝑘
= 𝑥 1 = 𝑥
𝑘 𝑘
𝑘=0 𝑘=0
100
𝑛
Special cases of 1 + 𝑥
Show that:
𝑛 𝑘 𝑛 𝑛−𝑚
=
𝑘 𝑚 𝑚 𝑘−𝑚
103
Example 30
Show that:
𝑛 𝑘 𝑛 𝑛−𝑚
=
𝑘 𝑚 𝑚 𝑘−𝑚
Solution. The left-hand side counts the ways to select a group of 𝑘 people
chosen from a set of 𝑛 people, and then to select a subset of 𝑚 leaders
within the group of 𝑘 people.
The right-hand side, first select the subset of 𝑚 leaders from the set of 𝑛
people and then select the remaining 𝑘 − 𝑚 members of the group from the
remaining 𝑛 − 𝑚 people. 104
Well-known binomial identities
𝑛 𝑛 𝑛 𝑛 (1)
+ + + ⋯+ = 2𝑛
0 1 2 𝑛
𝑛 2 𝑛 2 𝑛 2 𝑛 2 2𝑛 (4)
+ + + ⋯+ =
0 1 2 𝑛 𝑛
105
Well-known binomial identities
𝑚
𝑚 𝑛 𝑚+𝑛 (5)
=
𝑘 𝑟−𝑘 𝑟
𝑘=0
𝑚
𝑚 𝑛 𝑚+𝑛 (6)
=
𝑘 𝑟+𝑘 𝑚+𝑟
𝑘=0
𝑚
(7)
𝑚−𝑘 𝑛+𝑘 𝑚+𝑛+1
=
𝑘 𝑠 𝑟+𝑠+1
𝑘=0
106
Example 31
107
Example 31
𝑘!
𝑘−2 𝑘−2 𝑘 = = 𝑃 𝑘, 3 .
𝑘−3 !
108
Example 31
Furthermore, we have:
𝑘! 𝑃 𝑘, 3
𝐶 𝑘, 3 = = .
𝑘 − 3 ! 3! 3!
3 4 𝑛 3 4 𝑛 𝑛+1
3! + 3! + ⋯ + 3! = 3! + + ⋯+ = 3! .
3 3 3 3 3 3 4
109
Example 32
110
Example 32
111
Example 32
2 3 𝑛 1 2 𝑛
= 2 +2 + ⋯+ 2 + + + ⋯+
2 2 2 1 1 1
𝑛+1 𝑛+1
=2 +
3 2
112
Q&A
114