COUNTING
PIGEON HOLE :PRINCIPLE,
PERMUTATIONS,
COMBINATION
Lecture S
15
1
Tree Diagrams
We can solve many counting problems
through the use of tree diagrams
■ a branch represents a possible choice
■ the leaves of the tree represent possible
outcomes.
.
2
Example: Tree Diagrams
A T-shirt comes in five different sizes: S, M, L, XL,
and XXL. Each size comes in four colors: white, red,
green, and black, except
■ XL comes only in red, green, and black
■ XXL comes only in green and black.
What is the minimum number of T-shirts that a
store needs to stock to have one of each size and
color available?
Solution:
Draw the tree diagram.
17 T-shirts must be stocked.
3
PIGEONHOLE
PRINCIPLE
(6.2)
• Basic
principle
• Applications
4
The Pigeonhole Principle
If a flock of 26 pigeons roosts in a set of 25
pigeonholes, one of the pigeonholes must
have more than 1 pigeon.
https://en.wikipedia.org/wiki/
Pigeonhole_principle
5
The Pigeonhole Principle
Pigeonhole Principle:
If k is a positive integer and k + 1 objects are
placed into k boxes, then at least one box
contains two or more objects.
Proof: We use a proof by contradiction.
Suppose none of the k boxes has more than
one object. Then the total number of objects
would be at most k. This contradicts the
statement that we have k + 1 objects.
Example: Among any group of 367 people, there
must be at least two with the same birthday
because there are only 366 possible birthdays.
6
Example: Pigeonhole Principle
Every positive integer n has a multiple that
has only 0’s and 1’s in its decimal
expansion.
For example, for n=6, 1110 = 185×6.
Solution: Let n be a positive integer.
7
Every positive integer n has a multiple that
has only 0’s and 1’s in its decimal
expansion; e.g., for n=6, 1110 = 185×6.
Solution:
Let n be a positive integer.
Consider the n + 1 integers 1, 11, 111, ….,
11…1 (where the last integer has (n + 1)
1’s).
There are n possible remainders when an
integer
is divided by n.
Divide each of the n + 1 integers by n. By the
pigeonhole principle, at least two integers
must have the same remainder (i.e., s =
kn+r, t = jn+r)
Subtract the smaller from the larger.
The result is a multiple of n that has only 0’s 8
The Generalized Pigeonhole
Principle
The Generalized Pigeonhole Principle: If N
objects are placed into k boxes, then
least ⌈N/k⌉ objects.
there is at least one box containing at
contain at most ⌈N/k⌉ -1 objects, the
Prove by contradiction: If all boxes
total number of objects cannot be N.
Example: Among 100 people there are
⌈100/12⌉ = 9 who were born in the
at least
9
Example: Generalized Pigeonhole Principle
How many cards must be selected from
a standard deck of 52 cards to
guarantee that
at least three cards of the same suit are
chosen?
Solution:
10
Example: Generalized Pigeonhole Principle
How many cards must be selected from
a standard deck of 52 cards to
guarantee that
at least three cards of the same suit are
chosen?
Solution:
Assume there are four boxes, one for each
suit. We place cards in the box reserved
for its suit.
least one box contains at least ⌈N/4⌉ cards.
After N cards have been placed into boxes, at
At least three cards of one suit have been
⌈N/4⌉ ≥3.
selected if
11
Pigeonhole Principle Example (sort of…)
How many cards must be selected from a
standard deck of 52 cards to guarantee that at
least three hearts are selected?
Solution:
A deck contains 52 cards and 13
hearts. Hence, 39 cards are not
hearts.
If we select 41 cards, we may have 39 cards
which are not hearts along with 2 hearts.
However, when we select 42 cards, we must
have at
least three hearts.
12
PERMUTATIONS AND
COMBINATIONS
(6.3)
• Permutations and r-
permutations
• Combinations and r-
combinations
• Binomial coefficients
1
3
Permutations
Definition: A permutation of a set of distinct objects
is an ordered arrangement of these objects.
An ordered arrangement of r elements of a set is
called an r-permutation.
Example: Let S = {1,2,3}.
The ordered arrangement 3,1, 2 is a permutation
of S. The ordered arrangement 3, 2 is a 2-
permutation of S.
14
Permutations
The number of r-permutations of a set with n
elements is denoted by P(n,r).
The 2-permutations of S =
{1,2,3} are 1,2; 1,3; 2,1;
2,3; 3,1; 3,2
Hence, P(3,2) = 6.
P(n,r) = n(n-1)(n-2) … (n-r+1)
with 1 ≤ r ≤ n
15
Solving Counting Problems by
Counting Permutations
Example: How many ways are there to select a
third-prize winner from 100 different people who
first-prize winner, a second prize winner, and a
have entered a contest?
Solution:
P(100,3) = 100 ∙ 99 ∙ 98 = 970,200
16
Solving Counting Problems by Counting
Permutations
Example: Suppose a saleswoman has to visit
eight different cities. She must begin her trip
in a specified city, but she can visit the other
seven cities in any order.
How many possible orders exist?
Solution: The first city is chosen, and the rest are
ordered arbitrarily. Hence the orders are:
7! = 7 ∙ 6 ∙ 5 ∙ 4 ∙ 3 ∙ 2 ∙ 1 = 5040
If you need to find the tour with the shortest path
that visits all the cities, do you need to consider
all 5040 paths?
17
Theorem: If n is a positive integer and r is an
integer with 1 ≤ r ≤ n, then there are
𝑛
𝑃 𝑛, 𝑟 = n(n −
!
(n − r + 1) =
𝑛−𝑟
1)(n − 2) ∙∙∙
!
r-permutations of a set with n distinct elements.
Proof: Use the product rule.
– The first element can be chosen in n ways.
– The second element can be chosen in n−1
ways,
.
.
– until there are (n − ( r − 1)) ways to choose
the last element.
Note: P(n,0) = 1. There is only one way to
order zero elements. 18
Solving Counting Problems by
Counting Permutations
Example: How many permutations of the
letters
ABCDEFGH contain the string ABC ?
Solution: We solve this problem by counting
the permutations of six objects, ABC, D, E, F,
G, and H.
6! = 6 ∙ 5 ∙ 4 ∙ 3 ∙ 2 ∙ 1 = 720
19
Combinations
Definition: An r-combination of elements of a set
is an unordered selection of r elements from
the set.
An r-combination is a subset with r elements.
The number of r-combinations of a set with n
distinct elements is denoted by C(n, r).
Notation: 𝐶
�
𝑛, 𝑟 =
is called a binomial
�
�
coefficient.
�
20
Example: Combinations
S = {a, b, c, d}
{a, c, d} is a 3-combination from S.
It is the same as {d, c, a} since the order
does not matter.
C(4,2) = 6
The 2-combinations of set {a, b, c, d} are
six subsets:
{a, b}, {a, c}, {a, d}, {b, c}, {b, d}, and {c,
d}.
21
Combinations
Theorem: The number of r-combinations of a set
with n
elements, n ≥ r ≥ 0, is
Proof:
The P(n,r) r-permutations of the set can be
obtained by
– forming the C(n,r) r-combinations and then
– ordering the elements in each which can be
done in r! ways
By the product rule P(n, r) = C(n,r) ∙ r!
The result follows.
22
Useful identities
𝑃
𝑛, 𝑟
𝐶 𝑛, 𝑟 =
𝑟!
𝑃 𝑛, 𝑟 = 𝐶𝑛, 𝑟 ⋅
𝑟!
𝐶 𝑛, 𝑟 = 𝐶𝑛, 𝑛
−𝑟
23
Example: Combinations
from a standard deck of 52 cards?
How many poker hands of five cards can be dealt
Solution: Since the order in which the cards are
dealt does not matter, the number of five
card hands is:
24
Example: Combinations
How many ways are there to select 47 cards
from a deck of 52 cards?
The different ways to select 47 cards from 52
is
25
Combinations
Corollary: Let n and r be nonnegative integers,
r ≤ n.
Then C(n, r) = C(n, n − r).
Proof:
Since and
C(n, r) =
C(n, n − r)
follows.
26