Professional Documents
Culture Documents
Chapter 6
Counting
Combinatorial Analysis
The study of the numbers of ways of
selecting, or arranging, objects from a
finite set.
Many applications in network analysis,
discrete probability, analysis of
algorithms, graph theory, computational
geometry,
Examples
How many bit strings of length n?
How many subsets of a set of
cardinality n?
How many functions are there from a
set with m elements to a set with n
elements?
|A| + |B|
Example
University president is either a student
or a professor
There are 1000 professors, 25000
students
How many possible the presidents?
|A| + |B| - |A B|
Example
How many bit strings of length 8 either
start with 1 or end with 00?
Answer
Choose seat 1, order clockwise
4 people for seat 1
3 people for seat 2 etc
4x3x2x1 = 24 ways
Permutations
How many ways to order n distinct
objects
n! by the product rule
r-permutations
How many ways to choose an ordered
set of r things out of n distinct objects
Again by the product rule
n (n-1)(n-2)(n-r+1)
Notation
P(n,r) : number of permutations of a set
with n elements
Can you find a formula for P(n,r)?
P(n, r) = n (n-1)(n-2)(n-r+1)
= n! / (n-r)!
Note: 0! = 1
Combination formula
P(n, r )
n!
C (n, r ) =
=
P(r , r ) r!(n r )!
Combinations
An r-combination of elements of a set S,
is an unordered selection of r elements
from S.
Notation
C(n,r): the number of r combinations of
an n element set
Also denoted by
n
Combination formula
P(n, r )
n!
C (n, r ) =
=
P(r , r ) r!(n r )!
A useful identity
Let n and r be non-negative integers
with r n. Then C(n,r) = C(n,n-r)
Proof: ?
Binomial Coefficients
Application of combinations
Polynomial expansion
(x+y)3
= (x+y)(x+y)(x+y)
= x3+ x2y + x2y + x2y + xy2+ xy2+ xy2+ y3
= x3+ 3 x2y + 3 xy2+ y3
The coefficient of x2y is 3 because when choosing x
twice and y once, there are C(3,2) = C(3,1) = 3 ways
to choose where the x comes from
The coefficient of xy2 is 3 because when choosing x
once and y twice, there are C(3,2) = C(3,1) = 3 ways
to choose where the y comes from
Polynomial expansion
Consider: (x+y)5=x5+5x4y+10x3y2+10x2y3+5xy4+y5
To obtain the x5 term
Each time you multiple by (x+y), you select the x
Thus, of the 5 choices, you choose x 5 times: C(5,5) = 1
Alternatively, you choose y 0 times: C(5,0) = 1
n n j j
( x + y ) = x y
j = 0 j
n
Example
Cookie shop has 4 types of cookies
How many ways to buy 4 cookies?
Pigeonhole principle
If k+1 or more objects (pigeons) are
placed into k boxes, then there is at
least one box containing two or more of
the objects
Tree diagrams
A systematic way of counting
exhaustively
Starting from the root, branch at every
choice: count the number of leaves
Generalizes the product rule
Example
How many different ways a best of five
series can end
Each game is win or lose, no ties.
Example 22 on page 395
ADDITIONAL EXAMPLES
Pigeonhole Examples
How many balls are required if there are 2 colors, and one color must
have 3 balls?
number of boxes: k = 2, We want N/k = 3
What is the minimum N?
N=5
Example
Show that among any n+1 positive integers
not exceeding 2n, there must be an integer
that divides one of the other integers.
See the solutions for quiz 6
There are two solutions
One by induction
One by pigeonhole
Alternative Solution By
Piegonhole
Counting Passwords
Passwords can be 6 to 8 characters
long (letters or digits)
Not case sensitive
Each password contains at least one
digit
How many passwords are there?
Example
How many permutations of {a, b, c, d, e, f, g}
end with a?
Note that the set has 7 elements
Combinations example
How many different poker hands are
there (5 cards)?
C(52, 5) = 2,598,960
Examples
Example
Suppose there are 9 teams in the west
conference and 11 teams in the east
conference
We would like to form an NBA
committee by picking 3 executives from
the West and 4 from the East.
Each team can send at most 1
executive
How many possible committees?
Answer
9! 11!
C (9,3) C (11,4) =
= 84 220 = 27,720
3!6! 4!7!
Question
How many ways are there for 4 horses
to finish if ties are allowed?
Solution by cases
Answer
By the product rule, there are 6*6 = 36 possibilities for this case
Solution technique
Imagine we have a cash box for seven
types of bills with a compartment for
each type.
Represent this using 6 separators
100 | 50 | 20 | 10 | 5 | 2 | 1
Solution (cont)
So the problem has been reduced to
the number of ways of arranging six |s
and five *s
Whats the answer?
C(6+5, 5)
In general
There are C(n+r-1, r) ways of choosing r
objects with repetition from n classes
(i.e r-combinations with repetition from a
set with n elemens)
Example
a+b+c = 11
a,b,c are non-negative integers
How many solutions are there?