Solution. Both sides count the number of{0,1,2}-strings of lengthn, the right hand
side first partitioning them according to positions in the string which are not2. (For instance, if6of the positions are not2, we must first choose those6positions inC(n,6) ways and then there are26ways to fill in those six positions by choosing either a0or a1for each position.)
Example 2.20. Explain why, for each non-negative integern,
( 2n n ) ( n 0 )2 + ( n 1 )2 + ( n 2 )2 +· · ·+ ( n n )2 .
Solution. Both sides count the number of bit strings of length2nwith half the bits
being0’s, with the right side first partitioning them according to the number of 1’s occurring in the firstn positions of the string. Note that we are also using the trivial identity(nk)(nn−k).
2.5 The Ubiquitous Nature of Binomial Coefficients
In this section, we present several combinatorial problems that can be solved by ap- peal to binomial coefficients, even though at first glance, they do not appear to have anything to do with sets.
Example 2.21. The office assistant is distributing supplies. In how many ways can he
distribute 18 identical folders among four office employees: Audrey, Bart, Cecilia and Darren, with the additional restriction that each will receive at least one folder?
Imagine the folders placed in a row. Then there are 17 gaps between them. Of these gaps, choose three and place a divider in each. Then this choice divides the folders into four non-empty sets. The first goes to Audrey, the second to Bart, etc. Thus the answer isC(17,3). InFigure 2.22, we illustrate this scheme with Audrey receiving6 folders, Bart getting1, Cecilia4and Darren 7.
Figure 2.22:Distributing Identical Objects into Distinct Cells
Example 2.23. Suppose we redo the preceding problem but drop the restriction that
each of the four employees gets at least one folder. Now how many ways can the dis- tribution be made?
Solution. The solution involves a “trick” of sorts. First, we convert the problem to one that we already know how to solve. This is accomplished byartificiallyinflating everyone’s allocation by one. In other words, if Bart will get7folders, we say that he will get8. Also, artificially inflate the number of folders by4, one for each of the four persons. So now imagine a row of22 18+4 folders. Again, choose3 gaps. This determines a non-zero allocation for each person. The actual allocation is one less— and may be zero. So the answer isC(21,3).
Example 2.24. Again we have the same problem as before, but now we want to count
the number of distributions where only Audrey and Cecilia are guaranteed to get a folder. Bart and Darren are allowed to get zero folders. Now the trick is to artificially inflate Bart and Darren’s allocation, but leave the numbers for Audrey and Cecilia as is. So the answer isC(19,3).
Example 2.25. Here is a reformulation of the preceding discussion expressed in terms
of integer solutions of inequalities.
We count the number of integer solutions to the inequality
x1+x2+x3+x4+x5+x6 ≤538
subject to various sets of restrictions on the values ofx1,x2, . . . ,x6. Some of these
restrictions will require that the inequality actually be an equation. The number of integer solutions is:
1. C(537,5), when allxi >0and equality holds; 2. C(543,5), when allxi ≥0and equality holds;
3. C(291,3), whenx1,x2,x4,x6 >0,x352,x5194, and equality holds;
4. C(537,6), when allxi >0and the inequality is strict (Imagine a new variablex7
which is the balance. Note thatx7must be positive.);
5. C(543,6), when allxi ≥ 0and the inequality is strict (Add a new variablex7as
above. Now it is the only one which is required to be positive.); and 6. C(544,6), when allxi ≥0.
A classical enumeration problem (with connections to several problems) involves counting lattice paths. Alattice pathin the plane is a sequence of ordered pairs of integers:
(m1,n1),(m2,n2),(m3,n3), . . . ,(mt,nt) so that for alli1,2, . . . ,t−1, either
2.5 The Ubiquitous Nature of Binomial Coefficients
1. mi+1mi+1andni+1ni, or
2. mi+1miandni+1ni+1.
InFigure 2.26, we show a lattice path from(0,0)to(13,8).
(0,0)
(13,8)
Figure 2.26:A Lattice Path
Example 2.27. The number of lattice paths from(m,n)to(p,q)isC((p−m)+(q−n),p− m).
To see why this formula is valid, note that a lattice path is just anX-string with
X{H,V}, whereHstands forhorizontalandVstands forvertical. In this case, there are exactly(p−m)+(q−n)moves, of whichp−mare horizontal.
Example 2.28. Letnbe a non-negative integer. Then the number of lattice paths from
(0,0)to(n,n)which never go above the diagonal line yxis theCatalan number
C(n) 1 n+1 ( 2n n ) .
To see that this formula holds, consider the familyP of all lattice paths from(0,0) to(n,n). A lattice path from(0,0)to(n,n)is just a {H,V}-string of length2n with exactlyn H’s. So|P| (2nn). We classify the paths inP asgoodif they never go over the diagonal; otherwise, they arebad. A strings ∈ P is good if the number ofV’s in an initial segment ofs never exceeds the number ofH’s. For example, the string “HHV HVV HHHV HVVV” is a good lattice path from(0,0)to(7,7), while the path “HV HV HHVVV HV HHV” is bad. In the second case, note that after 9moves, we have5V’s and4H’s.
LetGandB denote the family of all good and bad paths, respectively. Of course, our goal is to determine|G|.
Consider a paths ∈ B. Then there is a least integeri so thatshas moreV’s than
H’s in the firstipositions. By the minimality ofi, it is easy to see thatimust be odd (otherwise, we can back up a step), and if we seti 2j+1, then in the first2j+1 positions ofs, there are exactlyj H’s andj+1V’s. The remaining2n−2j−1positions (the “tail ofs”) haven−j H’s andn−j−1V’s. We now transformsto a new string
s′by replacing theH’s in the tail of sbyV’s and theV’s in the tail ofs byH’s and leaving the initial2j+1positions unchanged. For example, seeFigure 2.29, where the pathsis shown solid ands′agrees withsuntil it crosses the lineyxand then is the dashed path. Thens′is a string of length2nhaving(n− j)+(j+1)n+1V’s and (n−j−1)+jn−1H’s, sos′is a lattice path from(0,0)to(n−1,n+1). Note that there are(n2−n1)such lattice paths.
(0,0)
(n,n) (n-1,n+1)
Figure 2.29:Transforming a Lattice Path
We can also observe that the transformation we’ve described is in fact a bijection betweenBandP′, the set of lattice paths from(0,0)to(n−1,n+1). To see that this is true, note that every paths′inP′must cross the line yx, so there is a first time it crosses it, say in positioni. Again,imust be odd, soi2j+1and there are j H’s and
j+1V’s in the firstipositions ofs′. Therefore the tail ofs′containsn+1−(j+1)n−j V’s and(n−1)−j H’s, so interchangingH’s andV’s in the tail ofs′creates a new string
sthat hasn H’s andn V’s and thus represents a lattice path from(0,0)to(n,n), but it’s still a bad lattice path, as we did not adjust the first part of the path, which results