Date post: | 27-Dec-2015 |
Category: |
Documents |
Upload: | estella-terry |
View: | 215 times |
Download: | 0 times |
15-299 Lecture 11 Feb 17, 1998 Doug Beeferman
Carnegie Mellon University
Count your blessings...
…faster!
Warm-upsWarm-ups
How many different ways areHow many different ways are
there to seat 121 students in a lecture roomthere to seat 121 students in a lecture room
of 214 chairs?of 214 chairs?
Q.Q.
!93
!214)1121214(212213214
!93
!214!121
!93!121
!214!121
121
214
How many different ways areHow many different ways arethere to seat 121 students in a lecture roomthere to seat 121 students in a lecture room
of 214 chairs?of 214 chairs?
There are often multiple ways to count the same setThere are often multiple ways to count the same set
1. Choose which seats are filled, then order the students in them1. Choose which seats are filled, then order the students in them
2. Assign an unfilled seat to each student in a 2. Assign an unfilled seat to each student in a fixed succession, fixed succession, e.g.e.g. alphabetically. alphabetically.
An easier oneAn easier one
How many different subsets ofHow many different subsets of
sleeping students are possible in this classsleeping students are possible in this class
of 121 students?of 121 students?
Q.Q.
How many different subsets ofHow many different subsets ofsleeping students are possible in this classsleeping students are possible in this class
of 121 students?of 121 students?
There are often multiple interpretations of the same countThere are often multiple interpretations of the same count
1212• Subsets of a 121-element setSubsets of a 121-element set
• Binary digit strings of length 121Binary digit strings of length 121
• Outcomes of flipping a penny 121 timesOutcomes of flipping a penny 121 times
• Possible committees drawn from 121 peoplePossible committees drawn from 121 people
kn
k
n xk
nx
0
)1(
Review: Review: The binomial formulaThe binomial formula
)(
0
)( knkn
k
n yxk
nyx
k
k
kn
k
n
xk
n
xk
nx
0
0
)1(
““Closed formClosed form” or” or““Generating formGenerating form” or” or““Generating functionGenerating function””
““Power seriesPower series” (“” (“Taylor seriesTaylor series”) expansion”) expansion
The binomial formulaThe binomial formula, take two, take two
nkk
n
if 0 Since
r
r
r
kr
kkk
nkkkkkkkk r
nr
xxxxkkkk
n
xxxx
321
321
321
321;;;; 321
321
;;;;
)(
Review: Review: The multinomial The multinomial formulaformula
!!!!
!
321 rkkkk
n
Multinomial maniaMultinomial mania
Q.Q.What Is the coefficient of (M•A•G•G•S) in theWhat Is the coefficient of (M•A•G•G•S) in the
expansion of (S+M+A+G)expansion of (S+M+A+G)5 5 ??
The same as the number of arrangementsThe same as the number of arrangementsof “MAGGS”, orof “MAGGS”, or
A.A.
601;2;1;1
5
!2
!5
Explore different possible representations of Explore different possible representations of
the same information or idea,the same information or idea,
and understandand understand
the relationship between them.the relationship between them.
Playing with Playing with the binomial the binomial formulaformula
n
k
n
kn
k
n
k
n
xk
nx
0
0
2
)1(
Can you explain this combinatorially?
Let x=1. We find that
Playing with Playing with the binomial the binomial formulaformula
n
k
n
k
n
0
2
The number ofThe number ofsubsets of an subsets of an nn-element set-element set
The number of The number of kk-element subsets of-element subsets ofan an nn-element set, summed over-element set, summed over
all possible all possible kk. .
Indeed, these mean the same thing!Indeed, these mean the same thing!
Combinatorial proofsCombinatorial proofs
A A combinatorial proofcombinatorial proof demonstrates demonstrates
that each side of an equationthat each side of an equation
corresponds to the size of the same set.corresponds to the size of the same set.
Contrast this to a conventional Contrast this to a conventional algebraic proofalgebraic proof,,
in which symbol manipulation is used toin which symbol manipulation is used to
carry one side to the othercarry one side to the other
MoreMore binomial formulations binomial formulations
1
odd even
0
0
2
)1(0
)1(
nn
k
n
k
kn
k
kn
k
n
k
n
k
n
k
n
xk
nx
Let x= -1. We find that
…or equivalently, that
The odds get evenThe odds get even
n
k
n
k k
n
k
n
odd even
The number ofThe number oflength-length-nn binary strings with binary strings with
an an even number of ones number of ones
The algebra has spoken. But it’s not yetThe algebra has spoken. But it’s not yetindependently clear why these sides count the same thing.independently clear why these sides count the same thing.
Let’s develop a Let’s develop a correspondencecorrespondence from one to the other. from one to the other.
The number ofThe number oflength-length-nn binary strings with binary strings with
an an oddodd number of ones number of ones
More odds and evensMore odds and evensLet Let OOnn be the set of`binary strings of length be the set of`binary strings of length nn with with
an odd number of ones.an odd number of ones.Let Let EEnn be the set of`binary strings of length be the set of`binary strings of length nn with with
an even number of ones.an even number of ones.
We have already presented an algebraicWe have already presented an algebraicproof that proof that OOnn =E=Enn
An elegant combinatorial proof can be had byAn elegant combinatorial proof can be had byputting putting OOn n and and EEn n in in one-to-one correspondence.one-to-one correspondence.
The The correspondence principlecorrespondence principle says that says thatif two sets can be placed in one-to-one if two sets can be placed in one-to-one
correspondence, then they are the same sizecorrespondence, then they are the same size!!
An attempt at a correspondenceAn attempt at a correspondence
Let Let ffnn be the function that takes an be the function that takes an nn-bit bitstring and flips all its bits.-bit bitstring and flips all its bits.
ffnn is clearly a one-to-one and onto function is clearly a one-to-one and onto function for odd for odd nn. . E.g.E.g. in in ff77 we have we have
0010011 0010011 1101100 11011001001101 1001101 0110010 0110010
...but do even ...but do even nn work? In work? In ff66 we have we have
110011 110011 001100 001100101010 101010 010101 010101
Uh oh. Complementing maps evens to evens!Uh oh. Complementing maps evens to evens!
A correspondence that works for all A correspondence that works for all nn
Let Let ffnn be the function that takes an be the function that takes an nn-bit bitstring and flips only -bit bitstring and flips only the first bitthe first bit..
For example,For example,
0010011 0010011 1010011 10100111001101 1001101 0001101 0001101
110011 110011 010011 010011101010 101010 001010 001010
CheckCheck::1. 1. ffnn : O: Onn EEnn??2.2. f fn n is one-to-one? is one-to-one? i.e.i.e. x x y y f fn n (x) (x) f fn n (y)(y)3.3. f fn n is onto? is onto? i.e.i.e. for all y for all y E Enn, , there exists an x there exists an x O Onn such that f such that fn n (x)=y(x)=y
How to countHow to countallocation schemesallocation schemes
Example 1:Example 1:Pirates and gold barsPirates and gold bars
ScenarioScenario: You’re a pirate who has just: You’re a pirate who has just
discovered discovered nn bars of gold (identical and indivisible). bars of gold (identical and indivisible).
Being a generous buc, you decide to split the loot Being a generous buc, you decide to split the loot
between the between the kk distinct shipmates on board. distinct shipmates on board.
How many ways are there to do this? How many ways are there to do this?
Example: n=4, k=3Example: n=4, k=3
… … 15 = allocation schemes!15 = allocation schemes!
Representation: Partition a string of 4 gold bars Representation: Partition a string of 4 gold bars
into 3 substrings by inserting slashes.into 3 substrings by inserting slashes.
13
134
Connecting to a known Connecting to a known representationrepresentation
So the number of allocation schemes So the number of allocation schemes is the is the
same assame as the number of strings of bars and slashes the number of strings of bars and slashes
with with nn bars and bars and k-1k-1 slashes... slashes...……which which is the same asis the same as the number the number
of waysof ways
to choose to choose k-1k-1 positions to make positions to make slashesslashes
from a set of from a set of n+k-1n+k-1 positions, or positions, or
1
1
k
kn
How to count allocation schemesHow to count allocation schemesExample 2:
Solutions to integer equations
Q. How many ways are there to solve:Q. How many ways are there to solve:
0,,
10
321
321
xxx
xxx
662
12
13
1310
A. It’s A. It’s the same as the same as distributing 10 gold bars to 3 pirates!distributing 10 gold bars to 3 pirates!
How to count allocation schemesHow to count allocation schemesExample 3:
Solutions to constrained integer equations
Q. A twist: what if the solutions must be strictly positive?Q. A twist: what if the solutions must be strictly positive?
0,,
10
321
321
xxx
xxx
362
9
13
137
A. First give every “pirate” his required 1 “gold bar”.A. First give every “pirate” his required 1 “gold bar”.Then count the ways to distribute the remaining 10-3=7 “gold bars”:Then count the ways to distribute the remaining 10-3=7 “gold bars”:
How to count pathwaysHow to count pathwaysMeandering in a nameless modern metropolis
Scenario: You’re in a city where all the streets,Scenario: You’re in a city where all the streets,numbered numbered 00 through through xx, run north-south,, run north-south,
and all the avenues, numbered and all the avenues, numbered 00 through through yy, , run east-west. How many [sensible] ways are there run east-west. How many [sensible] ways are there to walk from the corner of 0th St. and 0th avenue to to walk from the corner of 0th St. and 0th avenue to
the opposite corner of the city?the opposite corner of the city?
00
yyxx00
Meandering in a nameless modern metropolis
• All paths require exactly All paths require exactly x+yx+y steps: steps:• xx steps east, steps east, yy 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+yx+y steps are northward steps are northward steps:steps:
y
yx
yyxx00
00
(i,j)(i,j)
Now, what if we add Now, what if we add the constraint that the constraint that the path must go the path must go through a certain through a certain
intersection, call it intersection, call it (i,j)?(i,j)?
Meandering in a nameless modern metropolis• Given the constraint, we can decompose Given the constraint, we can decompose each valid path into two subpaths:each valid path into two subpaths:
• The subpath from the start to The subpath from the start to (i,j)(i,j)
• The subpath from The subpath from (i,j)(i,j) to to (y,x)(y,x)
yyxx00
00
(i,j)(i,j)
i
ji
•These subpaths These subpaths may be may be independently independently chosen. By the chosen. By the product rule, the product rule, the total path count istotal path count is
)(
)()(
iy
jxiy
)(
)()(
iy
jxiy
i
ji
k
n
k
n
k
n 1
1
1
An important identity for binomial coefficientsAn important identity for binomial coefficients
Combinatorial proof? Consider Combinatorial proof? Consider separating all separating all kk-element subsets of the -element subsets of the
set set {1,2,…,n}{1,2,…,n} into those that include and into those that include and those that exclude those that exclude nnGraphical intuition:Graphical intuition:
Let Let n=x+yn=x+y be the total be the totalsteps needed in the city steps needed in the city walk problem, and let walk problem, and let
k=yk=y be the be thenumber of northward number of northward
steps.steps.There are two cases for There are two cases for
thethevery last step taken.very last step taken.
Toward Toward Pascal’s TrianglePascal’s Triangle
0
1
0
2
0
3
2
2
2
3
1
1
1
2
1
3
2
4
1
4
2
5
3
3
3
4
3
5
1
5
4
4
4
5
5
5
0
0
0
4
0
5
Associate with each intersection the path count from (0,0),Associate with each intersection the path count from (0,0),
k
n
Toward Toward Pascal’s TrianglePascal’s Triangle
1 1 1
1 3
1 2 3
6
4
10
1 4 10
5
1 5
1
1 1 1
Simplifying, we observe startling symmetriesSimplifying, we observe startling symmetries
Pascal’s TrianglePascal’s Triangle
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
Credited toCredited toBlaise Pascal, 1654Blaise Pascal, 1654
““It is extraordinary howIt is extraordinary howfertile in properties thefertile in properties thetriangle is. Everyonetriangle is. Everyonecan try his hand.”can try his hand.”
- Blaise- Blaise
Summing the rows… Summing the rows… gives us powers of 2gives us powers of 2
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
=1=1
=2=2
=4=4
=8=8
=16=16
=32=32
=64=64
n
k
n
k
n
0
2
Summing the diagonals…Summing the diagonals… yields Little Gauss’s formula and more!yields Little Gauss’s formula and more!
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
)1(
2
1
1
1
1
nnnii
k
n
k
i
n
ki
n
ki
n
ki
““It is extraordinary howIt is extraordinary howfertile in properties thefertile in properties thetriangle is. Everyonetriangle is. Everyonecan try his hand.”can try his hand.”
- Blaise- Blaise
Try your hand.Try your hand.