Combinatorics & Generating Functions

Study Sheet

Combinatorics & Generating Functions

Bijections, recurrences, generating functions, inclusion–exclusion, extremal arguments

Counting With Structure

Tip
Bijections before formulas

Pair objects with objects. Subsets of {1..10}\{1..10\} with even sum: toggle the element 11 — an involution swapping parity — so exactly half, 512512.

Dyck paths \leftrightarrow balanced parentheses \leftrightarrow triangulations (Catalan, Cn=1n+1(2nn)C_n = \tfrac{1}{n+1}\binom{2n}{n}, C5=42C_5 = 42, proved by the reflection bijection). Compositions of nn \leftrightarrow subsets of n1n - 1 gaps (2n12^{n-1}). Stars and bars: nonnegative solutions of x1++xk=nx_1 + \cdots + x_k = n \leftrightarrow arrangements of nn stars and k1k - 1 bars. A bijection is a proof; a formula is a claim.

Tip
Recurrences and generating functions

Set up ana_n by the first choice; solve by characteristic equation or by the generating function A(x)=anxnA(x) = \sum a_nx^n, which turns the recurrence into algebra.

Domino tilings of 2×n2\times n: tn=tn1+tn2t_n = t_{n-1} + t_{n-2} (Fibonacci; t10=89t_{10} = 89). Derangements: Dn=(n1)(Dn1+Dn2)D_n = (n-1)(D_{n-1} + D_{n-2}), or by inclusion–exclusion n!(1)kk!n!\sum\tfrac{(-1)^k}{k!} (D6=265D_6 = 265). Generating functions multiply when choices are independent: (1+x+x2+)k=(1x)k(1 + x + x^2 + \cdots)^k = (1-x)^{-k} is stars and bars, (1+xi)\prod(1 + x^i) counts partitions into distinct parts, and Vandermonde (ak)(bnk)=(a+bn)\sum\binom ak\binom{b}{n-k} = \binom{a+b}{n} is (1+x)a(1+x)b(1+x)^a(1+x)^b.

Tip
Inclusion–exclusion and extremal arguments

A1An=AiAiAj+|A_1\cup\cdots\cup A_n| = \sum|A_i| - \sum|A_i\cap A_j| + \cdots. And: the largest, smallest, or extreme object has the least room to misbehave.

PIE counts surjections, derangements, and "no two adjacent" arrangements. Extremal: among finitely many points not all collinear, a pair at minimum distance... ; in a tournament, the vertex with maximum out-degree...; the longest path in a graph has endpoints whose neighbors all lie on it. Pigeonhole with kn+1kn + 1 objects forces k+1k + 1 in a box; the Erdős–Szekeres theorem (n2+1n^2 + 1 reals contain a monotone subsequence of length n+1n + 1) is pigeonhole plus extremal, and it is a Putnam regular.

Side note
Graph theory at Putnam level

Degree sum =2E= 2|E|; a tree on nn vertices has n1n - 1 edges; bipartite iff no odd cycle; Mantel (n2/4\le n^2/4 edges triangle-free) and Turán; Hall's marriage condition; Euler's VE+F=2V - E + F = 2 for planar graphs (with E3V6E \le 3V - 6). Model anything with "pairs" or "relations" as a graph and these become available.

Try it
Try it: inclusion–exclusion

How many integers in {1,,1000}\{1, \ldots, 1000\} are divisible by none of 2,3,52, 3, 5?

1000(500+333+200)+(166+100+66)33=10001033+33233=2661000 - (500 + 333 + 200) + (166 + 100 + 66) - 33 = 1000 - 1033 + 332 - 33 = 266. (Approximately 1000122345=266.71000\cdot\tfrac12\cdot\tfrac23\cdot\tfrac45 = 266.7 ✓.)

Proofs & Why It Matters

Tip
Proof: the Catalan reflection

Lattice paths from (0,0)(0,0) to (n,n)(n,n) never rising above y=xy = x number 1n+1(2nn)\tfrac{1}{n+1}\binom{2n}{n}.

All paths: (2nn)\binom{2n}{n}. A BAD path touches the line y=x+1y = x + 1; reflect the portion after its first touch across that line — it now ends at (n1,n+1)(n - 1, n + 1). This is a bijection between bad paths and all paths to (n1,n+1)(n-1, n+1), of which there are (2nn1)\binom{2n}{n-1}. Good paths: (2nn)(2nn1)=1n+1(2nn)\binom{2n}{n} - \binom{2n}{n-1} = \tfrac{1}{n+1}\binom{2n}{n}. \blacksquare Significance: the reflection principle also solves the ballot problem and gambler's ruin — one bijection, three theorems.

Tip
Proof: Erdős–Szekeres

Any sequence of n2+1n^2 + 1 distinct reals has a monotone subsequence of length n+1n + 1.

Label each term aia_i with (ui,di)(u_i, d_i) = lengths of the longest increasing and longest decreasing subsequence ENDING at aia_i. For i<ji < j: if ai<aja_i < a_j then uj>uiu_j > u_i; if ai>aja_i > a_j then dj>did_j > d_i — so the labels are all distinct. If every ui,dinu_i, d_i \le n there are only n2n^2 possible labels for n2+1n^2 + 1 terms: pigeonhole. \blacksquare Significance: the proof is the template "assign labels that are forced to be distinct, then count labels" — a pigeonhole pattern that recurs across Putnam combinatorics.

Going Deeper: Worked Problems

Example
Worked: a generating-function count

How many ways can 2020 be written as an ordered sum of 11s, 22s, and 33s?

Step 1 — let cnc_n count such compositions; the first part is 11, 22, or 33: cn=cn1+cn2+cn3c_n = c_{n-1} + c_{n-2} + c_{n-3} (tribonacci), c0=1c_0 = 1, c1=1c_1 = 1, c2=2c_2 = 2.

Step 2 — the generating function is cnxn=11xx2x3\sum c_nx^n = \dfrac{1}{1 - x - x^2 - x^3} (each composition is a word in the "alphabet" x+x2+x3x + x^2 + x^3).

Step 3 — run the recurrence: 1,1,2,4,7,13,24,44,81,149,274,504,927,1705,3136,5768,10609,19513,35890,66012,1214151, 1, 2, 4, 7, 13, 24, 44, 81, 149, 274, 504, 927, 1705, 3136, 5768, 10609, 19513, 35890, 66012, 121415: c20=121415c_{20} = 121415.

Step 4 — growth rate 1.839\approx 1.839, the real root of x3=x2+x+1x^3 = x^2 + x + 1 — the generating function's smallest pole.

Example
Worked: an extremal argument

In a tournament (every pair of teams plays once, no ties), show some team TT has the property that every other team either lost to TT or lost to a team that lost to TT.

Step 1 — take TT with the MAXIMUM number of wins.

Step 2 — suppose some team SS is not reachable in 2\le 2 steps: SS beat TT, and SS beat every team that TT beat.

Step 3 — then SS has at least (wins of TT) +1+ 1 wins — the teams TT beat, plus TT itself — contradicting maximality. \blacksquare Choosing the extreme object made the contradiction one sentence long; that is the extremal principle at its cleanest.