Discrete MathematicsBinomial Coefficients and Pascal's Triangle4 of 4
Binomial Coefficients and Pascal's Triangle · 4
Block Walking, Lattice Paths and Catalan Numbers
We need to count how many shortest paths lead from one corner of a street grid to another, both when the grid is wide open and when roadblocks or boundary lines get in the way.
1
Adding Corners and Routing Around Roadblocks
On a 4×3 grid from (0,0) to (4,3), a shortest path only steps Right and Up. Tracing routes one by one gets messy fast, so instead we count how many paths reach each intersection from the two corners that lead directly into it.
Adding Corners and Routing Around Roadblocks
Text solution
Fill the starting edges with 1'sEvery corner along the bottom edge and the left edge can only be reached by walking straight along that edge, so each one gets 1 path.
Add the corner to the left and the corner belowEvery inside corner (x,y) is entered either from (x−1,y) on its left or from (x,y−1) below it, reaching 35 paths at (4,3).
paths to (x,y)=paths to (x−1,y)+paths to (x,y−1)paths to (4,3)=20+15=35
Set a blocked corner to 0 and keep addingWhen (2,2) is closed for construction, no path can pass through it, so we write 0 at (2,2) and recompute the corners above it and to its right.
paths to (2,2)paths to (2,3)paths to (3,2)paths to (3,3)paths to (4,2)paths to (4,3)=0=4+0=4,=0+4=4=4+4=8,=4+5=9=8+9=17
So closing the single intersection (2,2) cuts the number of shortest paths from 35 down to 17.
Setting a blocked corner to 0 only changes the counts at intersections above it and to its right, and blocking a central intersection cuts the total at (4,3) far more than blocking a far corner like (0,3) or (4,0), which only 1 path ever reaches.
A roadblock sets its own corner to zero and only changes the corners above and to its right, which still add the corners to their left and below.
2
Grid Paths as Words of R's and U's
Adding corner by corner handles roadblocks easily, but on a large open grid we want to find the total number of paths from (0,0) to (m,n) without filling in every intersection. We can do that by writing each path as a word made of steps Right (R) and steps Up (U).
Grid Paths as Words of R's and U's
Text solution
Choose which slots get a U on the 4×3 gridEvery path from (0,0) to (4,3) is a 7-letter word with 4R's and 3U's, which is completely set once we pick which 3 of the 7 slots hold a U.
C(7,3)=3!4!7!=3×2×17×6×5=35
Split the walk at the (3,2) checkpointA path from (0,0) to (7,5) that passes through (3,2) walks 3 blocks Right and 2 blocks Up to reach (3,2), and then 7−3=4 blocks Right and 5−2=3 blocks Up from (3,2) to (7,5).
Start to (3,2)(3,2) to (7,5)Total pathsthrough (3,2)=C(3+2,2)=C(5,2)=10=C(4+3,3)=C(7,3)=35=10×35=350
So 350 shortest paths from (0,0) to (7,5) pass through the coffee shop at (3,2).
On any open grid from (0,0) to (m,n), every path takes m+n steps in total and chooses n of them to go Up (or m of them to go Right):
paths from (0,0) to (m,n)=C(total stepsm+n,steps Upn)=C(m+n,m)
3
Counting Paths Two Ways
Now we want to prove that the sum of the squares of row n of Pascal's triangle equals C(2n,n):
C(n,0)2+C(n,1)2+C(n,2)2+⋯+C(n,n)2=C(2n,n)
Instead of expanding factorials with algebra, we count the shortest paths from (0,0) to (n,n) in two ways: all at once, and split along the halfway line after n steps.
Counting Paths Two Ways
Text solution
Way 1: Count all paths to (4,4) at onceEvery path takes 8 steps total and chooses 4 of them to go Up.
C(8,4)=4×3×2×18×7×6×5=70
Way 2: Count paths through the halfway corner (4−k,k)After 4 steps, a path that has taken k steps Up and 4−k steps Right still needs 4−(4−k)=k steps Right during its last 4 steps to reach (4,4).
first 4 steps (choose k U’s)C(4,k)×last 4 steps (choose k R’s)C(4,k)=C(4,k)2
Add across all five halfway cornersBecause every 8-step path is at (4−k,k) for exactly one k∈{0,1,2,3,4} after its 4th step, summing the five cases gives the same 70 paths.
On an n×n grid, splitting every 2n-step walk after its first n steps proves C(n,0)2+C(n,1)2+⋯+C(n,n)2=C(2n,n).
4
Staying Below the Diagonal and the Catalan Numbers
Next, we stay on the square grid from (0,0) to (n,n) and add a boundary rule: we want to count how many paths never cross above the main diagonal y=x.
Staying Below the Diagonal and the Catalan Numbers
Text solution
Erase the corners above y=x and add corner by cornerBecause no path can step above the diagonal, every diagonal corner (k,k) can only be reached from (k,k−1) directly below it, carrying that count straight up.
C0C1C2C3C4C5=1=1=2=5=14=42 at (0,0), at (1,1), at (2,2) at (3,3), at (4,4), at (5,5)
Translate the diagonal rule into R's and U'sStepping above y=x means taking more U's than R's, so staying on or below the diagonal means that at every point from left to right:
number of R’s so far≥number of U’s so far
So 4 opening brackets `(` and 4 closing brackets `)` can be properly nested in C4=14 ways, and 4 customers with $5 bills (R) and 4 customers with $10 bills (U) can line up at an empty register in 14 different orders of bills without the cashier running out of change.
In this 4×4 walk, the path crosses above the diagonal y=x in red at the exact character where the number of closing brackets read from the left first goes past the number of opening brackets.
A walk of four R's and four U's crosses above the diagonal at the exact bracket where closing brackets outnumber the opening brackets read so far.
5
The Reflection Method
Adding corners up the grid found C4=14, but for a larger grid we want a direct combinations formula for the nth Catalan number Cn. Instead of counting the good paths directly, we count the bad paths (the ones that cross above y=x and touch the red forbidden line y=x+1) and subtract them from the total paths C(2n,n).
The Reflection Method
Text solution
Count all paths to (4,4) without the boundaryAny choice of 4R's out of 8 steps gives a path.
Total paths=C(8,4)=70
Flip every bad path after its first touch on the red line y=x+1At the first corner where a bad path touches y=x+1, it has taken 1 more U than R, so swapping every remaining R and U turns its 4R's and 4U's into 3R's and 5U's, matching bad paths to (4,4) one-to-one with all paths to (3,5).
Bad paths=C(8,3)=3×2×18×7×6=56
Subtract bad paths from total pathsRemoving the 56 bad paths leaves the 14 good paths that never cross above y=x.
C4=C(8,4)−C(8,3)=70−56=14
On any n×n grid, reflecting (n,n) across y=x+1 lands at (n−1,n+1). Since C(2n,n−1)=(n−1)!(n+1)!(2n)!=n+1nC(2n,n), the bad paths are always n+1n of the total (for n=4,56 is 54 of 70), and the good paths are the n+11 that's left (for n=4,51 of 70 is 14). That gives the formula for the nth Catalan number:
Cn=total paths to (n,n)C(2n,n)−bad paths, reflected to (n−1,n+1)C(2n,n−1)=n+11C(2n,n)
No matter which bad path you take from (0,0) to (4,4) or where its red dot first touches the forbidden line y=x+1, flipping every R and U after that dot always sends the orange reflected tail to the exact same corner, (3,5).
Interactive c3
6
Reflecting on Rectangular Grids and Shifted Boundaries
The Catalan formula Cn only applies when you have an equal number of R's and U's and the forbidden line is y=x+1. Now we want to count valid paths when there are more R's than U's (a rectangular walk from (0,0) to (6,3)) or when the register starts with $5 bills already inside (which shifts the red forbidden line up).
Reflecting on Rectangular Grids and Shifted Boundaries
Text solution
Empty register on a 6×3 grid (forbidden line y=x+1)Swapping (6,3) across y=x gives (3,6), and shifting 1 step left and 1 step up for y=x+1 lands every reflected bad path at (2,7).
Total paths to (6,3)Bad paths (to (2,7))Good paths=C(9,3)=84=C(9,2)=36=84−36=48
One starter $5 bill on a 6×3 grid (forbidden line y=x+2)With one $5 bill already in the drawer, the cashier only runs out of change when a path reaches 2 more U's than R's, shifting the red forbidden line to y=x+2 and shifting (3,6) by 2 steps left and 2 steps up to (1,8).
Bad paths (to (1,8))Good paths=C(9,1)=9=84−9=75
So starting with one $5 bill in the register raises the number of valid orders of bills from 48 to 75. In general, if you start with s starter supplies, you only run out when U's go past R's by c=s+1, putting the forbidden line at y=x+c.
7
The Catalan Recurrence
Some counting problems produce the Catalan numbers 1,1,2,5,14,42 even when there isn't a grid walk in sight. To recognize them, we find how each Catalan number Cn is built out of the earlier ones by grouping the valid paths from (0,0) to (n,n) according to the corner (k,k) where they touch the diagonal y=x for the very first time after leaving (0,0).
The Catalan Recurrence
Text solution
Count the walk up to the first return at (k,k)Because the path cannot touch y=x before (k,k), its first step must go Right to (1,0) and its step into (k,k) must come Up from (k,k−1), leaving a (k−1)×(k−1) Catalan walk between (1,0) and (k,k−1) in Ck−1 ways.
Multiply by the remaining walk from (k,k) to (4,4)From (k,k) to (4,4) is an ordinary (4−k)×(4−k) Catalan walk in C4−k ways, giving Ck−1C4−k paths whose first return to the diagonal is at (k,k).
Add across all four first-return corners k=1,2,3,4Using C0=1,C1=1,C2=2,C3=5:
For any n≥1, pairing the earlier Catalan numbers from the ends inward gives the Catalan recurrence:
Cn=C0Cn−1+C1Cn−2+C2Cn−3+⋯+Cn−1C0
8
Triangulating Polygons
Now we want to find how many ways a convex polygon can be sliced into triangles by diagonals that never cross each other. A hexagon always cuts into 4 triangles (and an (n+2)-sided polygon cuts into n triangles), and we can count the triangulations by looking at the single triangle that uses the yellow bottom edge.
Triangulating Polygons
Text solution
Pick the top vertex of the yellow bottom-edge triangleIn a hexagon (4 triangles), the third corner of the bottom-edge triangle must be one of the 4 top vertices, which splits the remaining 3 triangles into a Left polygon and a Right polygon.
Multiply the Left and Right counts and add across all 4 verticesMoving the tip from Vertex 1 on the far left to Vertex 4 on the far right splits the remaining 3 triangles into pairs of sizes (0,3),(1,2),(2,1), and (3,0).
So a hexagon has C4=14 triangulations, and any convex (n+2)-sided polygon (which cuts into n triangles) has Cn triangulations.
As the top vertex of the yellow bottom-edge triangle moves from left to right around the polygon, the Left and Right polygons trade one triangle at a time, stepping through the products C0Cn−1,C1Cn−2,…,Cn−1C0.
Every corner the bottom triangle's tip can land on splits the remaining 3 triangles of the hexagon between a Left polygon and a Right polygon.
Key concepts
When you are counting paths or structures built step by step, pick your method based on the obstacles in the grid:
Open grids vs. roadblocks
On an open grid from (0,0) to (m,n), every walk is an (m+n)-letter word with mR's and nU's, giving C(m+n,n) paths (for (4,3),C(7,3)=35). If a path must pass through (a,b), split the trip into two legs and multiply C(a+b,b)×C((m−a)+(n−b),n−b).When C(m+n,n) alone isn't the answer: if the grid has closed intersections, don't plug straight into C(m+n,n). Instead, fill the bottom and left edges with 1's, write 0 on every blocked corner, and add the corner to the left plus the corner below, one corner at a time.
Diagonal boundaries and the reflection method
If an n×n walk from (0,0) to (n,n) can never let U's outnumber R's (like n pairs of brackets or an empty register with n$5 bills and n$10 bills), the count is the nth Catalan number
Cn=C(2n,n)−C(2n,n−1)=n+11C(2n,n)
with C0=1,C1=1,C2=2,C3=5,C4=14,C5=42.When not to plug into Cn: if the grid is rectangular (m=n) or you start with s starter supplies (moving the red forbidden line to y=x+c where c=s+1), reflect the destination (m,n) across y=x+c by swapping to (n,m) and shifting c left and c up to (n−c,m+c), then subtract the bad paths C(m+n,n−c) from C(m+n,n) (for (6,3) across y=x+2, reflect to (1,8) to get C(9,3)−C(9,1)=75).
The Catalan recurrence
When a problem of size n splits at one first choice (such as a path's first return (k,k) to the diagonal, or the yellow bottom-edge triangle of an (n+2)-sided polygon) into two independent pieces of sizes k−1 and n−k, the count builds as
Cn=C0Cn−1+C1Cn−2+⋯+Cn−1C0
9
Practice
1
On a street grid, you walk from (0,0) to (8,5) taking only steps Right (R) and Up (U). How many shortest paths are there in total, and how many of them pass through the corner (5,2)?
Treat the walk through (5,2) as two back-to-back trips: first from (0,0) to (5,2), and then from (5,2) to (8,5). How many steps Right and Up are left for the second leg?
Every path from (0,0) to (8,5) takes 8+5=13 steps and chooses 5 to go Up, giving C(13,5)=1,287 total paths. A path through (5,2) walks from (0,0) to (5,2) in C(5+2,2)=C(7,2)=21 ways, and then has 8−5=3 steps Right and 5−2=3 steps Up left to reach (8,5) in C(3+3,3)=C(6,3)=20 ways. (Watch out: don't add the two legs to get 21+20=41, and don't forget to subtract (5,2) from (8,5) before counting the second leg.) Multiplying the two legs gives 21×20=420.
2
On a 4×4 grid from (0,0) to (4,4), intersections (1,2) and (3,1) are closed for construction. Find the number of shortest paths from (0,0) to (4,4) that avoid both closed intersections.
Watch out: at (3,2), add 3 from the left and 0 from (3,1) below; carrying up the unblocked count 4 from (3,1) gives 36 at the end instead of 24.
Put 1's along the bottom and left edges, place a 0 at both (1,2) and (3,1), and fill in the grid row by row by adding the corner to the left and the corner below.
Setting (1,2) and (3,1) to 0 and adding the corner to the left plus the corner below row by row from y=0 to y=4 gives:
Row y=0:1,1,1,1,1
Row y=1:1,2,3,0,1
Row y=2:1,0,3,3,4 (Watch out: at (3,2), add 3 from the left and 0 from (3,1) below; carrying up the unblocked count 4 from (3,1) gives 36 at the end instead of 24.)
Row y=3:1,1,4,7,11
Row y=4:1,2,6,13,24
3
How many arrangements of 6 opening parentheses `(` and 6 closing parentheses `)` are properly nested?
Watch out: C(12,6)=924 counts all arrangements without the nesting rule, and if you use n+11C(2n,n), divide by 6+1=7, not by 6 which gives 154.
Reading from left to right, a string of 6 `(` (R) and 6 `)` (U) is properly nested when it never crosses above y=x. Which Catalan number counts a 6×6 grid walk?
Properly nested arrangements of 6 pairs match paths from (0,0) to (6,6) that stay on or below y=x, which is the 6th Catalan number C6. (Watch out: C(12,6)=924 counts all arrangements without the nesting rule, and if you use n+11C(2n,n), divide by 6+1=7, not by 6 which gives 154.) Subtracting the reflected bad paths gives C6=C(12,6)−C(12,5)=924−792=132.
4
Tickets cost $5 and the cash register starts empty. If 7 customers have a $5 bill and 4 customers have a $10 bill, in how many orders can the 11 customers line up so the cashier never runs out of change? (Count two lines as the same order when they have the same sequence of $5 and $10 bills.)
Watch out: don't divide 330 by n+1 as if the grid were square, and don't stop at (4,7) without shifting by 1, which would subtract C(11,4)=330 and give 0.
This is a rectangular walk from (0,0) to (7,4) that cannot touch the forbidden line y=x+1. Where does (7,4) land when you swap its coordinates and shift 1 step left and 1 step up?
There are C(7+4,4)=C(11,4)=330 total paths from (0,0) to (7,4). Reflecting (7,4) across y=x+1 swaps the coordinates to (4,7) and shifts 1 step left and 1 step up to (3,8). (Watch out: don't divide 330 by n+1 as if the grid were square, and don't stop at (4,7) without shifting by 1, which would subtract C(11,4)=330 and give 0.) Subtracting the C(11,3)=165 bad paths to (3,8) gives 330−165=165.
5
Suppose 5 customers have a $5 bill and 5 customers have a $10 bill, but the cashier starts with two $5 bills already in the register. In how many orders can the 10 customers line up so the cashier never runs out of change? (Count two lines as the same order when they have the same sequence of $5 and $10 bills.)
Watch out: using y=x+2 shifts (5,5) to (3,7) and subtracts C(10,3)=120 bad paths, giving 132 instead of 207.
With two $5 bills already in the drawer, how many more $10 bills (U) than $5 bills (R) does it take to empty the register and hit the forbidden line y=x+c?
With 2 starter $5 bills, the cashier only runs out of change when a path reaches 2+1=3 more U's than R's, putting the forbidden line at y=x+3. (Watch out: using y=x+2 shifts (5,5) to (3,7) and subtracts C(10,3)=120 bad paths, giving 132 instead of 207.) Reflecting (5,5) across y=x+3 shifts 3 steps left and 3 steps up to (2,8), giving C(10,2)=45 bad paths out of C(10,5)=252 total paths, and 252−45=207.
6
How many paths from (0,0) to (6,6) stay below the diagonal y=x at every step and touch the diagonal only at the start (0,0) and the end (6,6)? How many paths from (0,0) to (6,6) stay on or below the diagonal and touch it for the first time after (0,0) at (2,2)?
A path whose first return to the diagonal is at (k,k) takes 1 forced step Right from (0,0) and 1 forced step Up into (k,k), shrinking the walk between them to size k−1. What is k in each question?
A path that touches the diagonal only at (0,0) and (6,6) has its first return at k=6, so its first step R to (1,0) and last step U from (6,5) are forced, shrinking the walk between them to a 5×5 Catalan walk in C5=42 ways (not C6=132). A path whose first return is at (2,2) has C2−1=C1=1 way from (0,0) to (2,2) (not C2=2, which would give 2×14=28) and C6−2=C4=14 ways from (2,2) to (6,6), giving C1C4=1×14=14.
7
In how many ways can a convex octagon (8-sided polygon) be sliced into 6 triangles by non-crossing diagonals? How many of those triangulations have the bottom edge belonging to a triangle whose tip splits the rest of the octagon into a quadrilateral on the left and a pentagon on the right?
Watch out: index by the number of triangles, not the number of sides; using sides gives C8=1,430 and C4C5=588.
Count how many triangles each polygon cuts into (2 fewer than its number of sides) to pick the right Catalan subscripts for the total and for the Left-and-Right split.
An 8-sided octagon cuts into 8−2=6 triangles in C6=C0C5+C1C4+C2C3+C3C2+C4C1+C5C0=42+14+10+10+14+42=132 ways. (Watch out: index by the number of triangles, not the number of sides; using sides gives C8=1,430 and C4C5=588.) A quadrilateral on the left (2 triangles, C2=2 ways) and a pentagon on the right (3 triangles, C3=5 ways) can be triangulated in C2C3=2×5=10.
8
Fix integers m≥n≥0. By counting shortest paths from (0,0) to (m,n) in two ways, first all at once and then split after the first m steps, prove that C(m,0)C(n,0)+C(m,1)C(n,1)+⋯+C(m,n)C(n,n)=C(m+n,n).
If a path takes k steps Up during its first m steps, it takes m−k steps Right in that first leg. How many steps Right does it still need during its final n steps?
Counting all at once, every path from (0,0) to (m,n) takes m+n steps with n steps Up, giving C(m+n,n) paths. Counting by splitting after the first m steps, a path that takes k steps Up in its first m steps (where 0≤k≤n) takes m−k steps Right, so it has m−(m−k)=k steps Right left to take during its final n steps. (Choosing which k of the final n steps go Right gives C(n,k) directly; choosing which n−k go Up gives C(n,n−k), which is the same number.) There are C(m,k) ways to choose the k Up-steps in the first m steps and C(n,k) ways to choose the k Right-steps in the last n steps, giving C(m,k)C(n,k) paths for each k. Summing over k=0,1,…,n counts every path to (m,n) once and gives C(m,0)C(n,0)+C(m,1)C(n,1)+⋯+C(m,n)C(n,n)=C(m+n,n).