Permutations: P (N, R) N! / (N-R) !
Permutations: P (N, R) N! / (N-R) !
2. C(n,r) = P(n,r) / r!
Why?
Each of the C(n,r) subsets of r objects can be
ordered in r! ways, meaning that C(n,r) * r! = P(n,r)
Computing Combinations
Computing C(n,r) as n! / [(n-r)!r!] is grossly inefficient and,
as a practical matter, can lead to incorrect results
(even using computers!).
Choose to compute
C(n,r) if r ≤ n/2 “and/or”
C(n,n-r) if r >n/2.
Then, assuming wlog we have the first case, compute C(n,r) as:
n (n-1)(n-2)(n-3)(n-4) … (n-r+2)(n-r+1)
r (r-1)(r-2) (r-3) (r-4) … (2) (1)
Q: How many 10-digit strings have four 1’s and no other repeats?
A: C(10,4) x P(9,6)
= C(10,4) x 9*8*7*6*5*4
Q: How many 10-digit strings have (exactly) four 1’s and three 2’s?
A: C(10,4) x C(6,3) x 83
= C(10,7) x C(7,4) x 83
Counting
Like 2n , C(n,r) and P(n,r), n! etc. grow very fast with n.
Behavior of C(n,r) and P(n,r) for fixed n=12 and growing r.
C(12,r) P(12,r)
r
r
Binomial Coefficients
Q: What is the coefficient of x12 y13 in the expansion of (x+y)25 ?
A: We need to pick 12 x’s from 25 terms: C(25,12) = C(25,13).
j 0 j 0 j
Some consequences:
n
2n C ( n, j ) How does this relate to |P(S)| = |2S| = 2|S| ?
j 0
n
0 (
j 0
1) j
C ( n, j )
n
3 2 C (n, j )
n j
j 0
Pascal’s Identity
C(n,j) = C(n-1,j-1) + C(n-1,j) if 1 ≤ j ≤ n-1
[Note that C(n,n)=C(n,0)=1 for all n]
You can select j objects from n in one of the following ways:
1. Take the first object and select j-1 from the last n-1 objects
OR
2. Omit the first object and select j from the last n-1 objects.
T
j T T
j-1 j
= +
a S a S a S
C(n , j) = C(n-1 , j-1) + C(n-1 , j)
Pascal’s Triangle
C(5,2)=C(4,1)+C(4,2) C(0,0)
C(1,0), C(1,1)
C(2,0), C(2,1), C(2,2)
C(3,0), C(3,1), C(3,2), C(3,3)
C(4,0),C(4,1),C(4,2),C(4,3),C(4,4)
C(5,0),C(5,1),C(5,2),C(5,3),C(5,4),C(5,5)
VanderMonde’s identity
r
C(m+n,r) = j 0
C(m,j)C(n,r-j) 0 ≤ r ≤ m,n
Proof:
Let Sm be a set with m elements; Sn, a set with n different elements.
Both sides of the equation equal |{A Sm Sn | |A|=r }| ,
the number of subsets of SmSn which have r elements.
remove r
m n m n m n m n
0 r 1 r-1 2 r-2
= + + +
…
Special case, m=n, using the fact that C(n,n-j)=C(n,j):
n
C(2n,n) = j 0
C(n,j)2 0≤j≤n
Another fact: C(n+1,r+1) = C(j,r)
n
j r
Example:
C(6,4) = C(5+1,3+1) = C(3,3) + C(4,3) + C(5,3) [r=3,n=5]
Proof:
Follows from Pascal’s identity:
C(n+1,r+1) = C(n,r) + C(n,r+1)
Q: How many 5 card hands can one get from a deck of 52 cards?
A: C(52,5) = _______
Now suppose you need to deal 3 such hands for 3 different players.
Q: How many ways can this be done if it matters who gets what hand?
A: 52!/(5!∙5!∙5!∙37!)
Q: How many ways if it doesn’t matter who gets what hand?
A: 52!/(3!∙5!∙5!∙5!∙37!)
Counting Examples, 4
A math teacher has 40 different issues of a journal to pack into 4 boxes,
10 issues each.
Q: How many ways can this be done if the boxes are numbered?
A: 40!/(10!)4
Q: How many ways can this be done if the boxes are not numbered?
A: 40!/(4!∙(10!)4)
Q: How many ways can one put n books on k shelves assuming each
shelf can hold at least n books?
A: Put them in order (n! ways) and then
decide where the k-1 shelf-breaks go (C(n+k-1,k-1) ways).
n!∙C(n+k-1,k-1) = (n+k-1)!/(k-1)!