CS311H: Discrete Mathematics Permutations and Combinations

advertisement
Announcements
CS311H: Discrete Mathematics
Permutations and Combinations
Instructor: Işıl Dillig
Instructor: Işıl Dillig,
CS311H: Discrete Mathematics
Permutations and Combinations
I
Homework 6 is out today; due next Thursday
I
Can leave answer in the form 232 – don’t have to calculate
exact answer
Suppose there is a flock of 36
pigeons and a set of 35 pigeonholes
I
Each pigeon wants to sit in one hole
I
But since there are less holes than
there are pigeons, one pigeon is left
without a hole.
Permutations and Combinations
2/37
I
Consider an event with 367 people. Is it possible no pair of
people have the same birthday?
I
Consider function f from a set with k + 1 or more elements to
a set with k elements. Is it possible f is one-to-one?
I
Consider n married couples. How many of the 2n people must
be selected to guarantee there is at least one married couple?
The Pigeonhole Principle: If n + 1 or more objects are placed
into n boxes, then at least one box contains 2 or more objects
CS311H: Discrete Mathematics
Permutations and Combinations
Instructor: Işıl Dillig,
3/37
Generalized Pigeonhole Principle
I
If n objects are placed into k boxes, then there is at least one
box containing at least dn/k e objects
I
Proof: (by contradiction) Suppose every box contains less
than dn/k e objects
CS311H: Discrete Mathematics
Permutations and Combinations
4/37
Examples
I
I
If there are 30 students in a class, at least how many must be
born in the same month?
I
What is the minimum # of students required to ensure at
least 6 students receive the same grade (A, B, C, D, F)?
I
I
I
I
What is the min # of cards that must be chosen to guarantee
three have same suit?
I
I
Instructor: Işıl Dillig,
CS311H: Discrete Mathematics
Examples
I
Instructor: Işıl Dillig,
Homework 5 is due today
Instructor: Işıl Dillig,
1/37
The Pigeonhole Principle
I
I
CS311H: Discrete Mathematics
Permutations and Combinations
Instructor: Işıl Dillig,
5/37
1
CS311H: Discrete Mathematics
Permutations and Combinations
6/37
Permutations
I
I
How Many Permutations?
A permutation of a set of distinct objects is an ordered
arrangement of these objects
I
No object can be selected more than once
I
Order of arrangement matters
I
Consider set S = {a1 , a2 , . . . an }
I
How many permutations of S are there?
I
Decompose using product rule:
Example: S = {a, b, c}. What are the permutations of S ?
I
How many ways to choose first element?
I
How many ways to choose second element?
I
...
I
How many ways to choose last element?
I
I
Instructor: Işıl Dillig,
CS311H: Discrete Mathematics
Permutations and Combinations
7/37
Instructor: Işıl Dillig,
Examples
CS311H: Discrete Mathematics
Permutations and Combinations
8/37
r -Permutations
I
Consider the set {7, 10, 23, 4}. How many permutations?
I
How many permutations of letters A, B, C, D, E, F, G contain
”ABC” as a substring?
I
I
I
Instructor: Işıl Dillig,
CS311H: Discrete Mathematics
Permutations and Combinations
9/37
r-permutation is ordered arrangment of r elements in a set S
I
S can contain more than r elements
I
But we want arrangement containing r of the elements in S
I
The number of r-permutations in a set with n elements is
written P (n, r )
I
Example: What is P (n, n)?
I
Instructor: Işıl Dillig,
Computing P (n, r )
CS311H: Discrete Mathematics
Permutations and Combinations
10/37
Examples
I
I
Given a set with n elements, what is P (n, r )?
I
Decompose using product rule:
I
What is number of permutations of set S ?
What is the number of 2-permutations of set {a, b, c, d , e}?
I
I
How many ways to pick first element?
I
How many ways to pick second element?
I
How many ways to pick i ’th element?
I
How many ways to pick last element?
Thus, P (n, r ) = n · (n − 1) . . . · (n − r + 1) =
I
How many ways to select first-prize winner, second-prize
winner, third-prize winner from 10 people in a contest?
I
n!
(n−r )!
I
Salesman must visit 4 cities from list of 10 cities: Must begin
in Chicago, but can choose the remaining cities and order.
I
How many possible itinerary choices are there?
I
Instructor: Işıl Dillig,
CS311H: Discrete Mathematics
Permutations and Combinations
11/37
Instructor: Işıl Dillig,
2
CS311H: Discrete Mathematics
Permutations and Combinations
12/37
Combinations
I
Number of r -combinations
An r-combination of set S is the unordered selection of r
elements from that set
I
I
The number of r -combinations of a set with n elements is
written C (n, r )
I
C (n, r ) is often also written as
I
I
Theorem:
Unlike permutations, order does not matter in combinations
I
Example: What are 2-combinations of the set {a, b, c}?
I
For this set, 6 2-permutations, but only 3 2-combinations
n
r
CS311H: Discrete Mathematics
Permutations and Combinations
Instructor: Işıl Dillig,
13/37
Proof of Theorem
What is the relationship between P (n, r ) and C (n, r )?
I
Let’s decompose P (n, r ) using product rule:
I
First choose r elements
I
Then, order these r elements
I
How many ways to choose r elements from n?
I
How many ways to order r elements?
I
Thus, P (n, r ) = C (n, r ) ∗ r !
I
Therefore,
, read ”n choose r”
n
r
CS311H: Discrete Mathematics
=
n!
r ! · (n − r )!
Permutations and Combinations
14/37
I
We need to create a team with 5 members out of 10
candidates. How many different teams are possible?
I
When creating a team, we don’t care about order in which
players were picked. Thus, we want C (n, r ), not P (n, r )
I
I
How many hands of 5 cards can be dealt from a standard
deck of 52 cards?
I
P (n, r )
n!
C (n, r ) =
=
r!
(n − r )! · r !
CS311H: Discrete Mathematics
Permutations and Combinations
Instructor: Işıl Dillig,
15/37
A Corollary
I
Examples
I
Instructor: Işıl Dillig,
n
r
is also called the binomial coefficient
C (n, r ) =
Instructor: Işıl Dillig,
CS311H: Discrete Mathematics
Permutations and Combinations
16/37
Another Example
Corollary: C (n, r ) = C (n, n − r )
I
There are 9 faculty members in a math department, and 11 in
CS department.
I
If we must select 3 math and 4 CS faculty for a committee,
how many ways are there to form this committee?
I
I
I
I
I
I
I
Instructor: Işıl Dillig,
CS311H: Discrete Mathematics
Permutations and Combinations
17/37
Instructor: Işıl Dillig,
3
CS311H: Discrete Mathematics
Permutations and Combinations
18/37
More Complicated Example
I
One More Example
I
How many bitstrings of length 8 contain at least 6 ones?
I
I
I
I
I
I
I
I
I
I
Instructor: Işıl Dillig,
CS311H: Discrete Mathematics
Permutations and Combinations
19/37
Instructor: Işıl Dillig,
Binomial Coefficients
I
Recall: C (n, r ) is also denoted as
n
r
and is called the
I
Binomial is polynomial with two terms, e.g., (a + b), (a + b)2
I
n
called binomial coefficient b/c it occurs as
r
coefficients in the expansion of (a + b)n
Instructor: Işıl Dillig,
CS311H: Discrete Mathematics
Permutations and Combinations
20/37
An Example
binomial coefficient
CS311H: Discrete Mathematics
Permutations and Combinations
I
Consider expansion of (a + b)3
I
(a + b)3 = (a + b)(a + b)(a + b)
I
= (a 2 + 2ab + b 2 )(a + b)
I
= (a 3 + 2a 2 b + ab 2 ) + (a 2 b + 2ab 2 + b 3 )
I
= 1a 3 + 3a 2 b + 3ab 2 + 1b 3
1
Instructor: Işıl Dillig,
21/37
The Binomial Theorem
I
How many bitstrings of length 8 contain at least 3 ones and 3
zeros?
3
3
CS311H: Discrete Mathematics
1
Permutations and Combinations
22/37
Example
Let x , y be variables and n a non-negative integer. Then,
(x + y)n =
n X
n
x n−j y j
j
I
What is the expansion of (x + y)4 ?
j =0
I
I
To get such a term, must choose n − j of the x ’s and j y’s
I
Once you pick n − j x ’s, # of y’s determined (and vice versa)
I
Since there is
Instructor: Işıl Dillig,
I
Proof: Each term in the expansion if of the form c · x n−j y j
n
n −j
n
coefficient c is
j
=
CS311H: Discrete Mathematics
n
j
4
1
I
;
I
Therefore,
=
4
3
=;
4
2
=
(x + y)4 = 1x 4 + 4x 3 y + 6x 2 y 2 + 4xy 3 + 1y 4
ways to pick x n−j ,
Permutations and Combinations
23/37
Instructor: Işıl Dillig,
4
CS311H: Discrete Mathematics
Permutations and Combinations
24/37
Another Example
I
Corollary of Binomial Theorem
What is the coefficient of x 12 y 13 in the expansion of
(2x − 3y)25 ?
I
I
Binomial theorem allows showing a bunch of useful results.
I
Corollary:
k =0
I
I
I
I
Instructor: Işıl Dillig,
CS311H: Discrete Mathematics
Permutations and Combinations
Corollary:
n
P
(−1)k
n
k
I
=0
Corollary:
I
CS311H: Discrete Mathematics
Permutations and Combinations
27/37
n
P
2k
Instructor: Işıl Dillig,
Pascal’s Triangle
n
k
26/37
Permutations and Combinations
28/37
= 3n
CS311H: Discrete Mathematics
Proof of Pascal’s Identity
n’th row consists of
n
k
Permutations and Combinations
Instructor: Işıl Dillig,
5
n
k −1
+
Proof:
n
k −1
+
n
k
Multiply first fraction by
29/37
=
I
for k = 0, 1, . . . n
CS311H: Discrete Mathematics
This identity is known as Pascal’s identity
Pascal arranged binomial coefficients as a triangle
n +1
k
I
I
Instructor: Işıl Dillig,
Permutations and Combinations
I
Instructor: Işıl Dillig,
I
= 2n
CS311H: Discrete Mathematics
k =0
I
I
n
k
One More Corollary
k =0
I
Instructor: Işıl Dillig,
25/37
Another Corollary
I
n
P
n
k −1
+
=
k
k
n
k
n!
n!
+
(k − 1)!(n − k + 1)! (k )!(n − k )!
and second by
n
k
=
CS311H: Discrete Mathematics
n−k +1
n−k +1 :
k · n! + (n − k + 1)n!
(k )!(n − k + 1)!
Permutations and Combinations
30/37
Proof of Pascal’s Identity, cont.
I
I
n
k −1
+
n
k
=
Interesting Facts about Pascal’s Triangle
k · n! + (n − k + 1)n!
(k )!(n − k + 1)!
Factor the numerator:
(n + 1) · n!
(n + 1)!
n
n
+
=
=
k −1
k
(k )!(n − k + 1)!
k ! · (n − k + 1)!
But this is exactly
n +1
k
I
What is the sum of numbers in n’th row in Pascal’s triangle
(starting at n = 0)?
I
Observe: This is exactly the corollary we proved earlier!
n X
n
= 2n
k
k =0
Instructor: Işıl Dillig,
CS311H: Discrete Mathematics
Permutations and Combinations
Instructor: Işıl Dillig,
31/37
Some Fun Facts about Pascal’s Triangle, cont.
I
I
I
Instructor: Işıl Dillig,
I
Earlier, when we defined permutations, we only allowed each
object to be used once in the arrangement
I
But sometimes makes sense to use an object multiple times
I
Example: How many strings of length 4 can be formed using
letters in English alphabet?
I
Since string can contain same letter multiple times, we want
to allow repetition!
I
A permutation with repetition of a set of objects is an ordered
arrangement of these objects, where each object may be used
more than once
Which of the theorems we proved today explains this fact?
CS311H: Discrete Mathematics
Permutations and Combinations
33/37
Instructor: Işıl Dillig,
Number of Permutations with Repetition
I
32/37
Numbers on left are mirror image of numbers on right
Instructor: Işıl Dillig,
I
Permutations and Combinations
Permutations with Repetitions
Pascal’s triangle is perfectly symmetric
I
CS311H: Discrete Mathematics
CS311H: Discrete Mathematics
Permutations and Combinations
34/37
General Formula for Permutations with Repetition
How many strings of length k can be formed using the 26
lower-case letters in the English alphabet?
I
P ∗ (n, r ) denotes number of r-permutations with repetition
from set with n elements
I
Theorem: P ∗ (n, r ) = n r
I
Proof: n ways to select first element, n ways to select second,
. . . , n ways to select r ’th element
I
By product rule, n r r-permutations with repetition are possible
Decompose using product rule:
I
How many ways to choose first letter?
I
How many ways to choose second letter?
I
...
How many possible strings?
CS311H: Discrete Mathematics
Permutations and Combinations
Instructor: Işıl Dillig,
35/37
6
CS311H: Discrete Mathematics
Permutations and Combinations
36/37
Examples
I
How many ways to assign 3 jobs to 6 employees if every
employee can be given more than one job?
I
How many different four-digit numbers can be formed from
the digits 1, 2, 3, 4?
I
How many different 3-digit numbers can be formed from
1, 2, 3, 4, 5?
Instructor: Işıl Dillig,
CS311H: Discrete Mathematics
Permutations and Combinations
37/37
7
Download