Combinatorics meets dynamic programming: when counting becomes computation
Dynamic programming is bottom-up evaluation of a recurrence; a generating function is its analytic closed form. We draw the correspondence between the knapsack DP and generating function multiplication, discuss convolution and FFT, and survey the connections across the entire series.
This final article in the series examines the intimate relationship between combinatorics and dynamic programming (DP) – the single most important algorithmic technique in competitive programming. DP and combinatorics are two sides of the same coin, and understanding their connection opens a far wider range of problem-solving strategies.
1 DP is bottom-up evaluation of a recurrence
2 The knapsack problem and generating functions
Each row of the DP table is the coefficient sequence of a polynomial.
The DP transition (using the previous row to compute the next) is polynomial multiplication.
The entire DP table is the step-by-step expansion of a generating function product.
3 Convolution and FFT
As discussed in the fourth article, the product of generating functions corresponds to convolution.
A naive computation takes time, but the Fast Fourier Transform (FFT) reduces this to .
Coefficient representation point-value representation (, via FFT).
Pointwise multiplication ().
Point-value representation coefficient representation (, via inverse FFT).
4 A retrospective of the series
Looking back across the eight articles, we can see how the topics in combinatorics form an organically connected whole.
The foundations of counting (addition and multiplication principles) – the starting point. Counting is cardinality.
Binomial coefficients (Pascal's identity, binomial theorem) – the most fundamental counting tool. Pascal's triangle is a DP table.
Inclusion–exclusion (alternating sums) – the technique of "subtract the bad cases." The binomial identity is the engine.
Generating functions (sequences as power series) – transforming recurrences into algebra. The analytic counterpart of DP.
Catalan numbers (reflection principle, bijections) – derived from a quadratic equation in the generating function. Bijections between parenthesizations and lattice paths.
The pigeonhole principle (existence proofs) – the power of non-constructive reasoning. The gateway to Ramsey theory.
Burnside's lemma (symmetry and group actions) – counting orbits via fixed-point averages.
DP and combinatorics (this article) – recurrence equals DP, generating function equals closed form, convolution equals FFT.
5 Beyond this introduction
Algebraic combinatorics: representation theory of groups and symmetric functions, Young tableaux and the Robinson–Schensted correspondence.
Probabilistic combinatorics: random graphs (the Erdos–Renyi model), the probabilistic method, the Lovasz Local Lemma.
Additive combinatorics: Szemeredi's theorem, the structure of sumsets.
Extremal combinatorics: Turan's theorem, the Kruskal–Katona theorem.
Matroid theory: the abstract structure underlying greedy algorithms and combinatorial optimization, touched upon in the graph theory series.
6 Takeaway
DP is bottom-up evaluation of a recurrence; Pascal's triangle is the prototype.
The knapsack DP corresponds to iterative polynomial multiplication in the generating function framework.
Convolution is the product of generating functions, and FFT accelerates it to .
The topics of this series – binomial coefficients, inclusion–exclusion, generating functions, Catalan numbers, Burnside's lemma – are all deeply intertwined with DP.
Beyond this series lies a vast landscape: algebraic, probabilistic, additive, and extremal combinatorics.
This concludes the eight-article "Between the Lines" series on combinatorics. The act of counting – the most primitive of mathematical operations – turns out to be a gateway to set theory, algebra, analysis, and algorithms. If this series has conveyed some sense of that unity, it has served its purpose.
Mathematics "between the lines" — exploring the intuition textbooks leave out, written in LaTeX on Folio.