The pigeonhole principle

The pigeonhole principle
  A drawer in a dark room contains red socks, green socks, and
blue socks. How many socks must you withdraw to be sure that
you have a matching pair?
A
1st sock
2nd sock
3rd sock
4th sock
 
f
B
red
green
blue
Four socks are enough to ensure a matched pair.
The pigeonhole principle
  If n pigeons fly into k pigeonholes with k < n, then some pigeonhole
contain at least two pigeons.
The pigeonhole principle
  If n pigeons fly into k pigeonholes with k < n, then some pigeonhole
contain at least two pigeons.
  We can use this simple little fact to prove complex things.
The pigeonhole principle
  If k is a positive integer and k + 1 or more object are placed into k
boxes, then there is at least one box containing two or more of the
objects.
proof by contrapositive
Suppose that none of the k boxes contains more than n object.
Then the total number of objects would be at most k.
This is a contradiction, because there are at least k + 1objects.
The pigeonhole principle
  When trying to solve a problem with the pigeonhole principle,
need to identify three things:
  The set A (the pigeons)
  The set B (the pigeonholes)
  The function f (the rule for assigning pigeons to pigeonholes)
Examples
  Among any group of 367 people, there must be at least two with
the same bday, because there are only 366 possible bdays.
  In a group of 27 English words, there must be at least two that
begin with the same letter because there are 26 letters in the
English alphabet.
Examples
  Show that in any set of six classes, each meeting regularly once a
week on a particular day of the week, there must be two that
meet on the same day, assuming that no classes are held in
weekends.
 
 
 
 
Pigeons:
There are six classes.
Pigeonholes: There are five days on which classes may meet.
Each class must meet on a day (each pigeon must occupy a
pigeonhole).
By the pigeonhole principle at least one day must contain at
least two classes.
Examples
  A drawer contains a dozen brown socks and a dozen black socks,
all unmatched. A man takes socks out at random in the dark.
  How many socks he must take out to be sure that he has at least
two socks of the same color?
  How many socks he must take out to be sure that he has at least
two black socks?
Next
  Counting
  Permutations
  Combinations
  Binomial coefficients
A chess problem
  In how many different ways can we place a pawn (p), a knight
(k), and a bishop (b) on a chessboard so that no two pieces
share a row or a column?
k
p
b
b
p
k
Permutations and combinations
  “My fruit salad is a combination of apples, grapes, and
bananas”.
  We don't care what order the fruits are in, they could also be
"bananas, grapes and apples" or "grapes, apples and
bananas", its the same fruit salad.
  “The combination of the safe is 472”.
  We do care about the order. "724" would not work, nor would
"247". It has to be exactly 4-7-2.
 
 
If the order doesn't matter, it is a combination.
If the order does matter it is a permutation.
Permutations
  Five athletes (Carole, Bob, Mark, Kelly and John) compete in
an Olympic event. Gold, silver and bronze medals are
awarded: in how many ways can the awards be made?
  Order matters!!!
  The case that Carole wins gold and Bob wins silver is different
from the case Bob wins gold and Carole wins silver.
Permutations
  If r objects are selected from a set of n objects, any particular
arrangement of these r objects (say, in a list) is called a
permutation.
  In other words, a permutation is an ordered arrangement of
objects.
  Let S = {a, b, c}
  c, b, a is a permutation of S
  b, c, a is a different permutation of S
Permutations
  An r-permutation is an ordered arrangement of r elements of
the set
  A♦, 5♥, 7♣, 10♠, K♠ is a 5-permutation of the set of cards.
  The number of r-permutations of a set of n elements is denoted
by P(n, r).
  Let S = {a, b, c}. The 2-permutation of S are the ordered
arrangements:
  a, b; a, c; b, a; b, c; c, a; c, b
  There are six 2-permutation of a set of 3 elements.
  P(3, 2) = 6; Permutations
  An r-permutation is an ordered arrangement of r elements of
the set
  A♦, 5♥, 7♣, 10♠, K♠ is a 5-permutation of the set of cards.
  The number of r-permutations of a set of n elements is denoted
by P(n, r).
  Let S = {a, b, c}. The 2-permutation of S are the ordered
arrangements:
  a, b; a, c; b, a; b, c; c, a; c, b
  There are six 2-permutation of a set of 3 elements.
  P(3, 2) = 6;  
The poker hand A♦, 5♥, 7♣, 10♠, K♠ is one of P(52, 5)
permutations.
Permutations
  Number of poker hands (5 cards):
  P (52,5) = 52 ⋅ 51⋅ 50 ⋅ 49 ⋅ 48 = 311875200
€
  THEOREM 1 If n is a positive integer and r is an integer with
1 ≤ r ≤ n, then there are
P ( n,r) = n ⋅ ( n − 1) ⋅ ( n − 2) ⋅… ( n − r + 1)
r-permutations of a set with n distinct elements.
€
Permutations
  THEOREM 1 If n is a positive integer and r is an integer with
1 ≤ r ≤ n, then there are
P ( n,r) = n ⋅ ( n − 1) ⋅ ( n − 2) ⋅… ( n − r + 1)
r-permutations of a set with n distinct elements.
€
proof: There
are n ways to choose the first element
n – 1 ways to choose the second
n – 2 ways to choose the third
…
n – r + 1 ways to choose the rth element.
By the product rule, that gives us: P(n, r) = n(n-1)(n-2)…(n-r+1)
Permutations
  COROLLARY 1: If n and r are integers with 0 ≤ r ≤ n, then
P ( n,r) =
€
n!
(n − r)!
Permutation calculation
  Background: Factorial notation
  1! = 1; 2! = 2·1 = 2 ; 3! = 3·2·1 = 6
  In general, n!= n(n-1)(n-2) ·…·3·2·1 for any positive integer n.
  It is customary to let 0! = 1 by definition.
  Calculation of permutation
P ( n,r) = n ⋅ ( n − 1) ⋅ ( n − 2) ⋅…⋅ ( n − r + 1)
n ⋅ ( n − 1) ⋅ ( n − 2) ⋅…⋅ ( n − r + 1)( n − r)!
=
(n − r)!
=
n!
(n − r)!
Permutations
  P(n, 0): There is only one ordered arrangement of zero objects, the
empty set.
n!
n!
P ( n,0) =
= =1
(n − 0)! n!
  P(n, 1): There are n ordered arrangements of one object.
n!
(
)
P
n,1
=
=n
€
(n − 1)!
  P(n, n): There are n! ordered arrangements of n distinct objects
(product rule)
€
€
P ( n,n ) =
n!
= n!
(n − n )!
Examples
  Five athletes (Carole, Bob, Mark, Kelly and John) compete in
an Olympic event. Gold, silver and bronze medals are
awarded: in how many ways can the awards be made?
 
The number of different ways to award the medals is the
number of 3-permuations of a set with 5 elements. Hence,
there are P(5, 3) = 5·4·3 = 60 possible ways to award the
medals.
Examples
  How many ways are there for 5 people in this class of 27
students to give presentations?
 
 
P(27,5) = 27·26·25·24·23 = 9,687,600
Note that the order they go in does matter in this example!
Examples
  How many permutations of the letters ABCDEFGH contain the
string ABC?
 
Because the letters ABC must occur as a block, we need to
find the number of permutations of 6 objects, no 8 (i.e. ABC,
D, E, F, G, H).
Because these six objects can occur in order, there are 6! =
720 permutations of the letters ABCDEFGH in which ABC
occurs as a block.
Combinations
  What if order doesn’t matter?
  In poker, the following two hands are equivalent:
  A♦, 5♥, 7♣, 10♠, K♠
  K♠, 10♠, 7♣, 5♥, A♦
Combinations
  A combination is the same as a subset.
  When we ask for the number of combinations of r objects
chosen from a set of n objects, we are simply asking:
  “How many different subsets of r objects can be chosen
from a set of n objects?”
  NOTE: The order doesn’t matter!
Combinations
  A r-combination of elements of a set is an unordered selection
of r elements from the set.
  Let S = {1, 2, 3, 4, 5}
  Then {1, 3, 4} is a 3-combination from S.
  The number of r-combinations of a set of n elements is denoted
by C(n, r).
  NOTE C(n, r) is also denoted by  n and is called a binomial
 r
coefficient.
€
Combinations
  THEOREM 2: The number of r-combinations of a set with n
elements, where n is a nonnegative integer and r is an integer
with 0 ≤ r ≤ n, equal
n!
C ( n,r) =
r!( n − r)!
proof: The r-permutations of a set can be obtained by forming
the C(n, r) r-combinations of the set , and then ordering the
elements in each r-combination, which can be done in P(r, r)
€ r) = C(n, r) · P(r, r).
ways. Thus, P(n,
C ( n,r) =
€
P ( n,r) n! ( n − r)!
n!
=
=
P ( r,r) r! ( r − r)! r!( n − r)!
Combinations
  For each combination, there are r! ways to permute the r
chosen object.
C(n, r) · r! = P(n, r)
Examples
  How many different poker hands are there (5 cards)?
52!
52! 52 ⋅ 51⋅ 50 ⋅ 49 ⋅ 48 ⋅ 47!
C (52,5) =
=
=
= 2598960
5!(52 − 5)! 5!47!
5 ⋅ 4 ⋅ 3⋅ 2 ⋅1⋅ 47!
 
€
In how many ways a committee of five can be selected from
among the 80 employees of a company?
80!
80! 80 ⋅ 79 ⋅ 78 ⋅ 77 ⋅ 76 ⋅ 75!
C (80,5) =
=
=
= 24040016
5!(80 − 5)! 5!75!
5 ⋅ 4 ⋅ 3⋅ 2 ⋅1⋅ 75!
€
Combinations simplification
  COROLLARY Let n and r be nonnegative integers with r ≤ n. Then
C(n, r) = C(n, n − r).
proof Form the theorem 2
n!
C ( n,r) =
r!( n − r)!
and
n!
n!
C ( n,n − r) =
=
€
(n − r)![ n − (n − r)]! (n − r)!r!
Hence, C(n, r) = C(n, n − r).
€
Combinations
  C(n, 0): There is only one way to chose 0 objects from the n objects
C ( n,0) =
n!
=1
0!( n − 0)!
  C(n, 1): There are n ways to select 1 object from n objects.
€
C ( n,1) =
n!
=n
1!( n − 1)!
  C(n, n): There is only one way to select n objects from n objects,
and that is to choose all the objects
€
n!
C ( n,n ) =
=1
n!( n − n )!
Combinatorial proof
  A combinatorial proof is a proof that uses counting arguments to
prove a theorem
  Rather than some other method such as algebraic techniques
  Essentially, show that both sides of the proof manage to count the
same objects.
  Proof outline:
  Define a set S
  Show that |S| = n by counting one way.
  Show that |S| = m by counting another way.
  Conclude that n = m
Permutations or Combinations ?
  The distinction between permutations and combinations lies in
whether the objects are to be merely selected or both selected
and ordered. If ordering is important, the problem involves
permutations; if ordering is not important the problem involves
combinations.
You want to count the number of …
Technique to try
Subsets of an n-element set
Use formula 2n
Outcomes of successive events
Multiply the number of outcomes for
each event
Outcome of disjoint events
Add the number of outcomes for each
event
Outcomes given specific choices at
each step
Draw a decision tree and count the
number of paths
Elements in overlapping sections of
related sets
Use principle of inclusion and
exclusion formula
Ordered arrangements of r out of n
distinct objects
Use P(n,r) formula
Ways to select r out of n distinct
objects
Use C(n,r) formula
Binomial coefficients
  Counting gives insight into one of the basic theorems of algebra.
  A binomial is a sum of two terms, e.g. a + b
  Consider (a + b)4:
(a + b) 4 = aaaa + aaab + aaba + aabb
+ abaa + abab + abba + abbb
+ baaa + baab + baba + babb
+ bbaa + bbab + bbba + bbbb
€
  There are 24 terms,
Binomial coefficients
  Consider (a + b)4:
(a + b) 4 = aaaa + aaab + aaba + aabb
+ abaa + abab + abba + abbb
+ baaa + baab + baba + babb
+ bbaa + bbab + bbba + bbbb
€
  Let’s group equivalent terms:
  aaab = aaba = abaa = baaa
  The coefficient of a n −k b k is  n
 
 k
  For n = 4
  There are 24 terms,
  The numbers of terms
with k copies of b and n – k
copies of a is:
 n
n!
= 
k!( n − k )!  k 
€
 4 4 0  4 3 1  4 2 2  4 1 3  4 0 4
€
(a + b) =   ⋅ a b €+   ⋅ a b +   ⋅ a b +   ⋅ a b +   ⋅ a b
 0
 1
 2
 3
 4
4
Binomial theorem
  THEOREM Let a and b be variables, and let n be a nonnegative
integer. Then
(a + b)
€
n
 n n −k k
= ∑  a b
k =0  k 
n
Binomial coefficient identities
from the binomial theorem
Pascal’s identity and triangle
  Let n and k be positive integers with n ≥ k. Then
 n   n  n + 1

 +  =

 k − 1  k   k 
proof
€
Pascal’s identity and triangle
 n  n
  Pascal’s identity, together with the initial conditions  0 =  n = 1
can be used to recursively define binomial coefficients.
€
Permutations with repetition
  How many strings of length r can be formed from the English
alphabet?
  This is an example of counting permutations when repetition of
elements is allowed.
  This is done by using the product rule
  Because there are 26 letters, and because each letter can be used
repeatedly, there are 26r strings of length r
Permutations with repetition
  Theorem 1: The number of r-permutations of a set of n objects
with repetition allowed is nr Combinations with repetition
  How many ways are there to select five bills from a cash box
containing $1 bills, $2 bills, $5 bills, $10bills, $20 bills, $50 bills,
and $100 bills? Assume that the order in which bills are chosen
does not matter, that the bills of each denomination are
indistinguishable, and that there are at least five bills of each
type.
  This problem involves counting 5-combinations with repetition
allowed from a set with seven elements. Combinations with repetition
  Theorem 2: There are C(n+r-1, r) = C(n+r-1, n-1) r-combinations
from a set with n elements when repetition of elements is
allowed.