76
Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8 Sept. 16, 2010 Carnegie Mellon University + + ( ) + ( ) = ?

Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

  • View
    213

  • Download
    1

Embed Size (px)

Citation preview

Page 1: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

Counting II: Pascal, Binomials, and Other Tricks

Great Theoretical Ideas In Computer Science

A. GuptaD. Sleator

CS 15-251 Fall 2010

Lecture 8 Sept. 16, 2010 Carnegie Mellon University

+ +( ) +( ) = ?

Page 2: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

Plan

Pirates and GoldPigeonhole PrincipalPascal’s TriangleCombinatorial ProofsManhattan Walk

Page 3: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

Permutations vs. Combinations

n!(n-r)!

n!r!(n-r)!

=nr

Ordered Unordered

Subsets of r out of n distinct objects

Page 4: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

How many ways to How many ways to rearrange the letters in rearrange the letters in the word the word “SYSTEMS”??

Page 5: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

SYSTEMS

7 places to put the Y, 6 places to put the T, 5 places to put the E, 4 places to put the M,

and the S’s are forced

7 X 6 X 5 X 4 = 840

_,_,_,_,_,_,_

Page 6: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

SYSTEMSLet’s pretend that the S’s are distinct:

S1YS2TEMS3

There are 7! permutations of S1YS2TEMS3

But when we stop pretending we see that we have counted each arrangement of SYSTEMS 3! times, once for each of 3! rearrangements of S1S2S3

7!

3!= 840

Page 7: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

Arrange n symbols: r1 of type 1, r2 of type 2, …, rk of type k

nr1

n-r1

r2

… n - r1 - r2 - … - rk-1

rk

n!

(n-r1)!r1!

(n-r1)!

(n-r1-r2)!r2!= …

=n!

r1!r2! … rk!

Page 8: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

How many ways to How many ways to rearrange the letters in rearrange the letters in

the word the word “CARNEGIEMELLON”??

14!

2!3!2!= 3,632,428,800

Page 9: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

Multinomial Coefficients

!!...rr!rn!

nr...rr if 0,

r;...;r;r

n

k21

k21

k21

Page 10: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

Four ways of choosing

We will choose 2-letters word from the alphabet (L,U,C,K,Y}

1) C(5,2) no repetitions, the order is NOT

important LU = UL

Page 11: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

Four ways of choosing

We will choose 2-letters word from the alphabet (L,U,C,K,Y}

2) P(5,2) no repetitions, the order is important LU != UL P(n,r)=n*(n-1)*…*(n-r+1)

Page 12: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

Four ways of choosing

We will choose 2-letters word from the alphabet (L,U,C,K,Y}

3) 52 =25 with repetitions, the order is important

Page 13: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

Four ways of choosing

We will choose 2-letter words from the alphabet {L,U,C,K,Y}

4) ???? repetitions, the order is NOT important

C(5,2) + {LL,UU,CC,KK,YY} = 15

Page 14: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

5 distinct pirates want to 5 distinct pirates want to divide 20 identical, divide 20 identical,

indivisible bars of gold. How indivisible bars of gold. How many different ways can many different ways can they divide up the loot?they divide up the loot?

Sequences with 20 G’s and 4 /’s

Page 15: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

Sequences with 20 G’s and 4 /’s

1st pirate gets 22nd pirate gets 13rd gets nothing4th gets 165th gets 1

GG/G//GGGGGGGGGGGGGGGG/Grepresents the following division among the

pirates

Page 16: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

Sequences with 20 G’s and 4 /’s

GG/G//GGGGGGGGGGGGGGGG/G

In general, the kth pirate gets the number of G’s after the k-1st / and before the kth /.

This gives a correspondence between divisions of the gold and sequences with 20 G’s and 4 /’s.

Page 17: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

How many different ways to divide up the loot?

24

4

205 -1

5 -1

How many sequences with 20 G’s and 4 /’s?

Page 18: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

How many different ways can n distinct pirates divide k

identical, indivisible bars of gold?

k

1kn

1-n

1-kn

Page 19: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

How many different ways to put k indistinguishable balls into n

distinguishable urns.

k

1kn

1-n

1-kn

Another interpretation

Page 20: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

How many integer solutions to the following equations?

0x,x,x,x,x

20xxxxx

54321

54321

Another interpretation

Think of xk as being the number of gold bars that are allottedto pirate k.

24

4

Page 21: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

How many integer nonnegative solutions to the following

equations?

0x,...,x,x

kxxx

n21

n21

...

k

1kn

1-n

1-kn

Page 22: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

How many integer positive solutions to the following

equations?x1 + x2 + x3 + … + xn = k

x1, x2, x3, …, xn > 0

bijection with solutions to

y1 + y2 + y3 + … + yn = k-ny1, y2, y3, …, yn ≥ 0

Think of xk -> yk+1

Page 23: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

Remember to distinguish betweenIdentical / Distinct Objects

If we are putting k objects into n distinct bins.

k objects are distinguishable

k objects are indistinguishable

n+k-1k

nk

Page 24: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

Pigeonhole Principle

If there are more pigeons than If there are more pigeons than pigeonholes, then some pigeonholes, then some

pigeonholes must contain two or pigeonholes must contain two or more pigeonsmore pigeons

Page 25: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

Pigeonhole Principle

If there are more pigeons than pigeonholes, If there are more pigeons than pigeonholes, then some pigeonholes must contain two or then some pigeonholes must contain two or

more pigeonsmore pigeons

Example:Example: two people in Pittsburgh must have the two people in Pittsburgh must have the same number of hairs on their headssame number of hairs on their heads

Page 26: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

Pigeonhole Principle

Problem:Problem: among any among any nn integer numbers, integer numbers, there are some whose sum is there are some whose sum is divisible by n.divisible by n.

Page 27: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

Among any Among any nn integer numbers, integer numbers, there are some whose sum is there are some whose sum is

divisible by n.divisible by n.

Exist sExist sii = s = skk (mod n). Take x (mod n). Take xi+1i+1 + … + x + … + xkk

Consider Consider ssii=x=x1 1 +…+x+…+xii modulo n. How many modulo n. How many ssii? ? Remainders are {0, 1, 2, …, n-1}.Remainders are {0, 1, 2, …, n-1}.

Page 28: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

Pigeonhole Principle

Problem:Problem: The numbers 1 to 10 are arranged in random order around a circle. Show that there are three consecutive numbers whose sum is at least 17.

What are pigeons? And what are pigeonholes?

Page 29: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

The numbers 1 to 10 are arranged in random order around a circle. Show

that there are three consecutive numbers whose sum is at least 17

Pigeons: SPigeons: S11+ .. + S+ .. + S1010= 3 (a= 3 (a11+a+a22+a+a1010) = 3*55 ) = 3*55 = 165= 165

Let SLet S11=a=a11+a+a22+a+a33, … S, … S1010=a10+a1+a2

There are 10 pigeonholes.There are 10 pigeonholes.

Since 165 > 10 *16, at least one pigeon-hole hasat least 16 + 1 pigeonsActually, we’re using a generalization of the PHPIf naturals x1+x2+…xn > k then one of xi > k/n

Page 30: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

Pigeonhole Principle

Problem:Problem: Show that for some integer k > 1, 3k ends with 0001 (in its decimal representation).

What are pigeons? And what are pigeonholes?

Page 31: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

Show that for some integer k > 1, 3k ends with 0001

33kk = 3 = 3m m mod (10000), m < kmod (10000), m < kChoose 10001 numbers: 3Choose 10001 numbers: 311,3,322,…, 3,…, 31000110001

33k-mk-m = q*10000 + 1 ends with 0001 = q*10000 + 1 ends with 000133k-mk-m = 1 = 1 mod (10000)mod (10000)

33kk - 3 - 3m m = 0 mod (10000), m < k= 0 mod (10000), m < k

33mm (3 (3k-mk-m - 1) - 1) = 0 mod (10000), m < k= 0 mod (10000), m < k

But 3 is relatively prime to 10000, soBut 3 is relatively prime to 10000, so

Page 32: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

Now, something completely Now, something completely different…different…

knkn

0k

n yx k

ny)(x

Page 33: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

POLYNOMIALS EXPRESS CHOICES AND OUTCOMES

Products of Sum = Sums of Products

+ +( ) +( ) =

++ + + +

Page 34: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

b2 b3b1

t1 t2 t1 t2 t1 t2

Page 35: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

b2 b3b1

t1 t2 t1 t2 t1 t2

b1

t1 b1

t2 b2 t2b2t1 b3 t1 b3 t2

(b1 + b2 + b3)(t1 + t2) = b1t1 + b1t2 + b2t1 + b2t2 + b3t1 + b3t2

Page 36: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

There is a correspondence

between paths in a choice tree and the cross terms of the

product of polynomials!

Page 37: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

1 X 1 X1 X 1 X

1 X 1 X

1 X

Choice tree for terms of (1+X)3

1 X X X2 X X2 X2 X3

Combine like terms to get 1 + 3X + 3X2 + X3

Page 38: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

1 X 1 X1 X 1 X

1 X 1 X

1 X

(1+X)3= 1 + 3X + 3X2 + X3

1 X X X2 X X2 X2 X3

What is the combinatorial meaning of those coefficients?

In how many ways canwe create a x2 term?

Page 39: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

What is a closed form expression for ck?

nn

2210

n xc...xcxccx)(1

In how many ways can we create a x2 term?

Page 40: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

What is a closed form expression for ck?

n times

ck, the coefficient of Xk, is the number of paths with exactly k X’s.

(1 X)

n

X X X X X( )( )( )( )...( )1 1 1 1 1

After multiplying things out, but before combining like terms, we get 2n cross terms, each corresponding to a path in the choice tree.

k

nck

Page 41: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

The Binomial Theorem

binomial expression

Binomial Coefficients

n2n xn

n...x

2

nx

1

n

0

nx)(1

Page 42: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

The Binomial Formula

knkn

0k

n yxk

ny)(x

Page 43: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

What is the coefficient of EMPTY in the expansion of

(E + M + P + T + Y)5 ?

5!

Page 44: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

What is the coefficient of EMP3TY in the expansion of

(E + M + P + T + Y)7 ?

The number of ways to rearrange the letters in the word SYSTEMS

Page 45: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

What is the coefficient of BA3N2 in the expansion of

(B + A + N)6?

The number of ways to rearrange the letters in the

word BANANA

Page 46: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

What is the coefficient of

in the expansion of

(X1+X2+…+Xk)n?

nr r r rk

!! ! !... !1 2 3

X X X Xr r rkrk

1 2 31 2 3 ...

Page 47: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

Multinomial Coefficients

n

r1;r2;...;rk

0, if r1 r2 ... rk nn!

r1!r2!...rk!

Page 48: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

The Multinomial Formula

i

k

, ,

r =n

3 k1 2

21 k

n

21

rrr r321 k

r r ...,r 21 k

X +X +...+ X

n= X X X ...Xr ;r ;...;r

Page 49: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

On to Pascal…

Page 50: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

The binomial coefficients have so many representations that

many fundamental mathematical identities

emerge…

0

(1 )n

n k

k

nx x

k

Page 51: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

Pascal’s Triangle:kth row are the coefficients of (1+X)k

(1+X)1 =

(1+X)0 =

(1+X)2 =

(1+X)3 =

1

1 + 1X

1 + 2X + 1X2

1 + 3X + 3X2 + 1X3

(1+X)4 = 1 + 4X + 6X2 + 4X3 + 1X4

Page 52: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

nth Row Of Pascal’s Triangle:

(1+X)1 =

(1+X)0 =

(1+X)2 =

(1+X)3 =

1

1 + 1X

1 + 2X + 1X2

1 + 3X + 3X2 + 1X3

(1+X)4 = 1 + 4X + 6X2 + 4X3 + 1X4

n

n...

2

n

1

n

0

n,,,,

Page 53: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

Pascal’s Triangle

11

1 + 11 + 1

1 + 2 + 11 + 2 + 1

1 + 3 + 3 + 11 + 3 + 3 + 1

1 + 1 + 44 + + 66 + 4 + 1 + 4 + 1

1 + 5 + 1 + 5 + 1010 + 10 + 5 + 1 + 10 + 5 + 1

1 + 6 + 15 + 20 + 15 + 6 + 11 + 6 + 15 + 20 + 15 + 6 + 1

Blaise Pascal 1654

k

1-n

1-k

1-n

k

n

Page 54: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

Summing The RowsSumming The Rows

11

1 1 ++ 1 1

1 1 ++ 2 2 ++ 1 1

1 1 ++ 3 3 ++ 3 3 ++ 1 1

1 1 ++ 4 4 ++ 6 6 ++ 4 4 ++ 1 1

1 1 ++ 5 5 ++ 10 10 ++ 10 10 ++ 5 5 ++ 1 1

1 1 ++ 6 6 ++ 15 15 ++ 20 20 ++ 15 15 ++ 6 6 ++ 1 1

=1=1

=2=2

=4=4

=8=8

=16=16

=32=32

=64=64

0

2n

n

k

n

k

Page 55: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

11

1 11 1

1 2 11 2 1

1 3 3 11 3 3 1

1 4 6 4 11 4 6 4 1

1 5 10 10 5 11 5 10 10 5 1

1 6 15 20 15 6 11 6 15 20 15 6 1

6+20+6 1+15+15+1=

nk

k even

nnk

k odd

n

=

Page 56: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

Summing on 1Summing on 1stst Avenue Avenue

11

1 11 1

1 2 11 2 1

1 3 3 11 3 3 1

1 4 6 4 11 4 6 4 1

1 5 10 10 5 11 5 10 10 5 1

1 6 15 20 15 6 11 6 15 20 15 6 1

21)n(n

2

1n

1

kk

n

1k

n

1k

Page 57: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

11

1 11 1

1 2 11 2 1

1 3 3 11 3 3 1

1 4 6 4 11 4 6 4 1

1 5 10 10 5 11 5 10 10 5 1

1 6 15 20 15 6 11 6 15 20 15 6 1

Summing on kSumming on kthth Avenue Avenue

1m

1n

m

kn

1k

Hockey-stickidentity

Page 58: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

11

1 11 1

1 2 11 2 1

1 3 3 11 3 3 1

1 4 6 4 11 4 6 4 1

1 5 10 10 5 11 5 10 10 5 1

1 6 15 20 15 6 11 6 15 20 15 6 1

=2

=5

=13

=3

=8

Fibonacci NumbersFibonacci Numbers

1n

2-n

0k

Fk

k-n

Page 59: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

1

1 1

1 2 1

1 3 3 1

1 4 6 4 1

1 5 10 10 5 1

1 6 15 20 15 6 1

Sums of Squares

2 2 2

2 2 2 2

2nn

nk

k = 0

n 2

=

Page 60: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

All these properties can be proved inductively and algebraically. We will give

combinatorial proofs.

The art of combinatorial proof

Page 61: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

The art of combinatorial proof

k-n

n

k

n

How many ways we can create a size k committee of n people?

LHS : By definition

RHS : We choose n-k people to exclude from the committee.

Page 62: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

The art of combinatorial proof

How many ways we can create a size k committee of n people?

LHS : By definition

RHS : Pick a person, say n.

1-k

1-n

k

1-n

k

n

There are committees that exclude person x

There are committees that include person x

Page 63: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

The art of combinatorial proof

How many ways we can create an even size committee of n people?

LHS : There are so many such committees

RHS : Choose n-1 people. The fate of the nth person is completely determined.

1nn

0k

22k

n

Page 64: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

The art of combinatorial proof

LHS : We create a size k committee, then we select a chairperson.

RHS : We select the chair out of n, then from the remaining n-1 choose a size k-1 committee.

1-k

1-n n

k

n k

Page 65: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

The art of combinatorial proof

LHS : Count committees of any size, one is a chair.

RHS : Select the chair out of n, then from the remaining n-1 choose a subset.

1nn

0k

2 nk

n k

Page 66: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

The art of combinatorial proof

LHS : m-males, n–females, choose size k.

RHS : Select a committee with j men, the remaining k-j members are women.

j-k

n

j

m

k

nm k

0j

Page 67: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

The art of combinatorial proof

LHS : The number of (k+1)-subsets in {1,2,…,n+1}

RHS : Count (k+1)-subsets with the largest element m+1, where k ≤ m ≤ n.

n

km k

m

1k

1n

Page 68: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

All these properties can be proved by using the

Manhattan walking representation of binomial

coefficients.

Page 69: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

Manhattan walkYou’re in a city where all the streets,You’re in a city where all the streets,

numbered numbered 0 through through x, run north-south,, run north-south,and all the avenues, numbered and all the avenues, numbered 0 through through y, , run east-west. How many [sensible] ways are run east-west. How many [sensible] ways are

there there to walk from the corner of 0th st. and 0th to walk from the corner of 0th st. and 0th

avenue to avenue to the opposite corner of the city?the opposite corner of the city?

00

yyxx00

Page 70: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

• All paths require exactly All paths require exactly x+y steps: steps:• x steps east, steps east, y steps north steps north• Counting paths is the same as counting Counting paths is the same as counting which of the which of the x+y steps are northward steps are northward steps:steps:

x y

y

Manhattan walk

yy(x,y)(x,y)00

Page 71: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

. . . . .. . . . .

. . . . .. . . . .

. . . . .

level nk’th Avenue1

1

1

1

1

1

1

1

1

11

3

2

3

4 46

156 6

5 510 10

1520

Manhattan walk

1-k

1-n

k

1-n

k

n

Page 72: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

Manhattan walk

01

23

4

01

23

4

1m

1n

m

kn

mk

We break all routes into: reach a star + 1 right and all left

turns

Page 73: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

. . . . .. . . . .

. . . . .. . . . .

. . . . .

1

1

1

1

1

1

1

1

1

11

3

2

3

4 46

156 6

5 510 10

1520

Manhattan walk

n

2n

k

nn

0k

2

Page 74: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

Now, what if we add the constraint that Now, what if we add the constraint that the path must go through a certain the path must go through a certain intersection, call it intersection, call it (n,k) ??

yy(2n,n)(2n,n)00

00

(n, k)(n, k)

Manhattan walk

n

2n

k

nn

0k

2

Page 75: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

The number of routes from (0,0) to (n,k) The number of routes from (0,0) to (n,k) isis

yy(2n,n)(2n,n)00

00

(n, k)(n, k)

Manhattan walk

k

n

The number of routes from (n,k) to (2n,n) The number of routes from (n,k) to (2n,n) is the same as from(0,0) to (n,n-k)is the same as from(0,0) to (n,n-k)

k-n

n

n

k

k0

n

n

n k

2n

n

Page 76: Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS 15-251 Fall 2010 Lecture 8Sept. 16,

Study Bee

• Binomials and

Multinomials

• Pirates and Gold

•Pigeonhole principal• Combinatorial proofs of binomial identities

•Manhattan walk