Last Week
We are going to count: The Art of Combinatorics
Thus far:
multiplying events
adding events
inclusion – exclusion principle
Today:
Permutations and Combinations
Binomials, Pascal’s Triangle
CS40, Wim van Dam, UCSB
Permutations / Combinations
How many ways can you order n elements?
Answer: n(n–1)(n–2)…1 = n! (say “n factorial”)
Note: 0!=1, 1!=1, 2!=2, 3!=6, 4!=24, …
How many ways can you order r out of n elements?
Answer: n(n–1)(n–2)…(n–r+1) = n! / (n–r)!
Sometimes denoted by P(n,r)
CS40, Wim van Dam, UCSB
Example:
Let there be 15 different people, in how many ways
can you line up 10 of them?
Answer: 1514…6 = P(15,10) = 10,897,286,400
Note how fast n! grows: n! = (2n)
CS40, Wim van Dam, UCSB
Binomial
How many ways can you select r elements out of n?
(without concern for the order of selection)
Answer:
You can order the r elements in n!/(n–r)! ways
Dividing out the r! orderings, gives you
n
P(n, r )
n!
C(n, r )
r!
(n r )! r!
r
Say: “n choose r”, or “the binomial of n over r”
CS40, Wim van Dam, UCSB
Examples:
Let there be 15 different people, in how many ways
can you select 10 of them?
Answer: C(15,10) = 15! / (10!5!) = 3003
I’m flipping a coin 20 times, in how many ways can I
have the outcome “heads” 10 times?
Answer: C(20,10) = 20! / (10!10!) = 184 756
… the outcome “heads” k times?
Answer: C(20,k) = 20! / ((20–k)!k!)
CS40, Wim van Dam, UCSB
Properties of Binomials
Because:
Also:
n
r
n!
r! (n r )!
we have
n
r
n
n r
n
n
n!
1
0! n!
0
n
n
n
n!
n
1! (n 1)!
1
n 1
n
n
n!
1
2 n(n 1)
2
2
!
(
n
2
)!
n
2
For constant c and variable n:
n
c
(nc )
CS40, Wim van Dam, UCSB
Binomial Theorem
Consider the n-fold product (a+b)n:
(a+b)(a+b)…(a+b) = an + nan–1b + n(n–1)/2an–2b2 +…+ bn
n n k k
Binomial Theorem (8.39): (a b) a b
k 0 k
n
n
Example: (a+b)4 = a4+4a3b+6a2b2+4ab3+b4
Immediate consequence:
(1 1)
n
n n k k
1 1
k 0 k
n
n
k 0 k
n
2n
CS40, Wim van Dam, UCSB
Bit Strings
Consider all bit strings of length n (all 2n of them).
The number of strings with k “ones” is C(n,k).
Hence indeed C(n,0)+C(n,1)+C(n,2)+…+C(n,n) = 2n.
We expect that ‘most’ strings will have n/2 ones.
Indeed, when we plot
C(20,k) for k=0,…,20,
we get the bell shaped
binomial distribution:
CS40, Wim van Dam, UCSB
Binomial Identity
Theorem 8.43: For all n,kN:
n
k
n 1 n 1
k 1 k
Proof by interpretation: “How can we pick k out of n?
…consider n–1…” et cetera (see book).
n 1 n 1
k 1 k
(n 1)!
(n 1)!
(k 1)! (n k )! (k )! (n k 1)!
k(n 1)!
(n k )(n 1)!
(k )! (n k )!
(k )! (n k )!
(n)(n 1)!
(k )! (n k )!
n!
(k )! (n k )!
n
k
CS40, Wim van Dam, UCSB
Triangle of Binomials
Because of the relation C(n,k) = C(n–1,k–1)+C(n–1,k),
we can write the binomials in a triangle:
3
0
2
0
1
0
3
1
0
0
2
1
1
1
3
2
Where on the ‘outside edges’
we have C(n,0)=C(n,n)=1
2
2
On the ‘inside’ we have
3
3
n 1
n 1
k 1
k
n
k
This gives…
CS40, Wim van Dam, UCSB
Pascal’s Triangle
By filling in the triangle of binomial values,
we get Pascal’s Triangle:
3
0
2
0
1
0
3
1
0
0
2
1
1
1
1
1
3
2
1
2
2
1
1
3
3
1
1
2
3
4
5
6
1
3
6
10
15
1
1
4
10
20
1
5
15
1
6
1
For large n, the values
on a row (like 1,4,6,4,1)
behave like a smooth
bell curve: the Gaussian
CS40, Wim van Dam, UCSB
Binomials and Bits
Consider a random n bit string x1,…,xn with xj{0,1}.
The probability of this string is 2–n,
the probability of k “ones” in the string is C(n,k)/2n
The binomial distribution for large n
teaches us that, although we expect
half of the n bits to be “one”,
the probability of k=½ n will be:
n
1
2 n
2n
2 1
n
Instead, we can expect the number of “ones”
to be between k = ½ n – n and ½ n + n
CS40, Wim van Dam, UCSB
© Copyright 2026 Paperzz