CS 2336 Discrete Mathematics: Counting: Permutations and Combinations
CS 2336 Discrete Mathematics: Counting: Permutations and Combinations
Discrete Mathematics
Lecture 8
Counting: Permutations and Combinations
1
Outline
• Definitions
• Permutation
• Combination
• Interesting Identities
2
Definitions
• Selection and arrangement of objects appear in
many places
We often want to compute # of ways to
select or arrange the objects
• Examples :
1. How many ways to select 2 people
from 5 candidates ?
2. How many ways to arrange 7 books
on the bookshelf ?
3
Definitions
• In most textbooks, we use the word
combination selection
• Example :
{ c, d } is a 2-combination of { a, b, c, d, e }
4
Definitions
• In most textbooks, we use the word
permutation arrangement
• Example :
cabd is a 4-permutation of { a, b, c, d, e }
5
Definitions
• Further, we define the following notation:
• What are the values of C(n, n), C(n, 1), C(3, 2),
and P(3, 2) ?
6
Test Your Understanding
7
Permutation
• In fact, there is a formula for P(n, r) :
P(n, r) = n (n – 1)(n – 2) … (n – r + 1)
• Proof :
P(n, r) = # ways to get r of n objects in some order.
There are n ways to choose the 1st object,
n – 1 ways to choose the 2nd object, … ,
n – r + 1 ways to choose the rth object
Result follows from rule of product
8
Examples
• Ex 1 : How many ways to select a first-prize, a
second-prize, and a third-prize winners
from 100 different people ?
• Ex 2 : How many ways can n people be ordered
to form a ring ?
2 1
1 3
3 2
9
With Indistinguishable Objects
• How many different strings can be made by re-
ordering the letters of the word “SUCCESS” ?
• Answer :
First, suppose that all the 7 letters are distinct.
Then, there will be 7! different strings.
Now, if we make the two Cs indistinguishable, we
will only have 7!/2! different strings.
Further, if the three Ss are indistinguishable, the
number of different strings becomes (7!/2!)/3!
10
With Indistinguishable Objects
• In general, if there are n objects, with
n1 indistinguishable objects of type 1,
n2 indistinguishable objects of type 2,
…,
nk indistinguishable objects of type k,
11
Examples
• If we have 5 dashes and 8 dots, how many
different ways to arrange them ?
...___._._ ...
12
Examples
• Show that for any positive integer k,
13
With Unlimited Repetitions
• Suppose that there are n distinct objects, each
with unlimited supply
• Answer : nr
14
Examples
• Ex 1 : Consider all numbers between 1 and 1010
(i) How many of them contain the digit 1 ?
(ii) How many of them do not ?
• Ex 2 :
(i) How many bit strings of length n are there ?
(ii) How many contain even number of 0s?
15
Combination
• Recall that
P(n, r) = P(r, r) C(n, r)
• Thus, we have
C(n, r) = n (n – 1)(n – 2) … (n – r + 1) / r!
C(n, r) = n! / ( (n – r)! r! )
16
Examples
• Consider a hexagon where no three diagonals
meet a one point
• Hint :
When the sum is a multiple of 3, what special
property does the 3 numbers have ?
18
Examples
• Five pirates have discovered a treasure box
They decided to keep the box in a locked room,
so that all the locks of the room can be opened
if and only if 3 or more pirates are present
19
With Unlimited Repetitions
• Suppose that there are n distinct objects, each
with unlimited supply
20
With Unlimited Repetitions
• Imagine we have a box for each type of objects
1 2 3
… n
1 2 3
… n
21
With Unlimited Repetitions
• To represent one of the r-combination, we may
use a list of n – 1 bars and r stars, where
the bars are used to mark off n different boxes
the stars are used to indicate how many balls
in each box
• For instance, suppose n = 5, r = 6
1 2 3 4 5 **|*| | |* **
22
With Unlimited Repetitions
• Using the bars-and-stars representation, we see
that
each r-combination corresponds to a unique
representation (with n – 1 bars and r stars), and
each representation (with n – 1 bars and r stars)
corresponds to a unique r-combination
# of r-combinations = # of representations
= C(n – 1 + r, r)
23
Examples
• Ex 1 : Suppose that a cookie shop has four
different kinds of cookies. How many
different ways can 6 cookies be chosen ?
24
Interesting Identities
Pascal’s Identity :
C(n, r) = C(n – 1, r) + C(n – 1, r – 1)
• Proof (by combinatorial arguments):
To select r of n objects, there are in two cases :
1. Get the first object, and then get r – 1 objects
from the remaining n – 1 objects ;
2. Do not get the first object, and get r objects
from the remaining n – 1 objects
In total, C(n – 1, r – 1) + C(n – 1, r) ways
25
Interesting Identities
Binomial Theorem :
n
(x + y)n =
r=0
C(n, r) xn – r yr
n
• Ex 5 : What is the value of
r=0
2 r C(n, r) ?
27
Interesting Identities
Vandermonde’s Identity :
r
C(m + n, r) = C(m, r – k) C(n, k)
k=0
• Answer :
Observe that
n n
k=0
C(n, k) 2 = C(n, n – k) C(n, k)
k=0
29