Unit 4: Recurrence Relations, Generating Functions & Divide-and-Conquer
Comprehensive mathematical theory of discrete difference equations: linear homogeneous recurrences with constant coefficients, characteristic polynomials and multiplicity degeneracies, non-homogeneous equations via undetermined coefficients and annihilators, divide-and-conquer relations and the Master Theorem, ordinary generating functions (OGF) for Catalan sequences, exponential generating functions (EGF), and recursive tree complexity analysis.
ยง4.1 Linear Homogeneous Recurrences & Characteristic Root Theory
1. General Form of Linear Homogeneous Recurrences
A linear homogeneous recurrence relation of degree $k$ with constant coefficients has the canonical algebraic form:
where $c_1, c_2, \dots, c_k$ are real or complex constants with $c_k \ne 0$, accompanied by $k$ initial conditions $a_0, a_1, \dots, a_{k-1}$.
2. Characteristic Polynomial and Root Multiplicities
We seek non-trivial geometric sequence solutions of the form $a_n = r^n$ with $r \ne 0$. Substituting $a_n = r^n$ into the recurrence relation:
Dividing both sides by $r^{n-k}$ yields the fundamental characteristic equation:
Theorem 4.1 (Distinct Roots Solution): If the characteristic polynomial has $k$ distinct real or complex roots $r_1, r_2, \dots, r_k$, then the general solution is:
where constants $\alpha_1, \dots, \alpha_k$ are uniquely determined by the initial conditions via the non-singular Vandermonde matrix:
Theorem 4.2 (Multiple Roots / Degeneracy): If a characteristic root $r_j$ occurs with multiplicity $m_j > 1$, then its contribution to the general solution is:
Summing across all distinct roots yields the full $k$-parameter vector space of solutions.
ยง4.2 Non-Homogeneous Recurrences: Undetermined Coefficients & Annihilators
1. Structure of Linear Non-Homogeneous Recurrences
A linear non-homogeneous recurrence relation has the form:
where $F(n)$ is a non-zero driving function.
Theorem 4.3 (Superposition Principle): The general solution of the non-homogeneous recurrence is the sum:
where $a_n^{(h)}$ is the general solution of the associated homogeneous equation, and $a_n^{(p)}$ is any particular solution of the non-homogeneous equation.
2. Method of Undetermined Coefficients
For standard forcing functions, trial particular solutions $a_n^{(p)}$ are selected based on the form of $F(n)$:
| Forcing Term $F(n)$ | Root Condition | Form of Particular Solution $a_n^{(p)}$ | | :--- | :--- | :--- | | Polynomial $P_d(n)$ of degree $d$ | $r = 1$ is not a root of char. eq. | $Q_d(n) = A_0 + A_1 n + \dots + A_d n^d$ | | Polynomial $P_d(n)$ of degree $d$ | $r = 1$ is a root of multiplicity $s$ | $n^s Q_d(n) = n^s (A_0 + A_1 n + \dots + A_d n^d)$ | | Exponential $c \cdot \lambda^n$ | $\lambda$ is not a characteristic root | $A \cdot \lambda^n$ | | Exponential $c \cdot \lambda^n$ | $\lambda$ is a root of multiplicity $s$ | $A \cdot n^s \lambda^n$ | | Mixed $P_d(n) \cdot \lambda^n$ | $\lambda$ is a root of multiplicity $s$ | $n^s (A_0 + A_1 n + \dots + A_d n^d) \lambda^n$ |
The unknown coefficients $A_i$ are determined by substituting $a_n^{(p)}$ directly into the recurrence equation and equating corresponding powers of $n$ and $\lambda^n$.
ยง4.3 Divide-and-Conquer Recurrences & The Master Theorem
1. Divide-and-Conquer Algorithm Complexity
Many foundational computer science algorithms (such as MergeSort, Karatsuba Integer Multiplication, and Strassen's Matrix Multiplication) divide a problem of size $n$ into $a$ subproblems of size $n/b$, solve them recursively, and combine their results in $f(n)$ work:
where $a \ge 1$, $b > 1$, and $f(n) \ge 0$ asymptotically.
2. The Master Theorem
The critical threshold exponent is:
which represents the asymptotic growth rate of work done at the leaf level of the recursion tree.
Theorem 4.4 (Master Theorem for Divide-and-Conquer): Let $T(n) = a T(n/b) + f(n)$.
- Case 1 (Leaf Dominant / Subproblems Dominate):
If $f(n) = O(n^{\log_b a - \epsilon})$ for some constant $\epsilon > 0$, then:
- Case 2 (Balanced / Even Work Across Tree Levels):
If $f(n) = \Theta(n^{\log_b a} \log^k n)$ for some integer $k \ge 0$, then:
(Standard case $k=0$ yields $T(n) = \Theta(n^{\log_b a} \log n)$).
- Case 3 (Root Dominant / Division & Combine Work Dominates):
If $f(n) = \Omega(n^{\log_b a + \epsilon})$ for some constant $\epsilon > 0$, and if $f(n)$ satisfies the regularity condition:
then:
ยง4.4 Ordinary Generating Functions (OGF) & Catalan Numbers
1. Formal Power Series and Ordinary Generating Functions
The ordinary generating function (OGF) of a sequence $(a_0, a_1, a_2, \dots)$ is the formal power series:
In formal algebraic power series, $x$ serves as a mathematical placeholder; questions of analytic radius of convergence are secondary to algebraic identities.
Fundamental Algebraic Operations:
- Sum: $\sum (a_n + b_n) x^n = A(x) + B(x)$.
- Cauchy Convolution (Product):
- Shifting:
- Differentiation:
2. The Catalan Sequence via Generating Functions
The Catalan numbers count the number of valid Dyck paths, binary search trees with $n$ nodes, and ways to parenthesize a string of $n+1$ factors. They satisfy Segner's non-linear convolution recurrence:
Multiplying by $x^n$ and summing over $n \ge 1$:
Thus, $C(x)$ satisfies the quadratic equation:
Solving via the quadratic formula:
(choosing the negative square root to satisfy $C(0) = \lim_{x \to 0} C(x) = 1$). Expanding via the generalized binomial theorem yields the celebrated formula:
ยง4.5 Exponential Generating Functions & Interactive Recurrence Tree Explorer
1. Exponential Generating Functions (EGF)
When counting ordered structures (such as labeled graphs, surjections, or permutations with restrictions), the exponential generating function (EGF) is standard:
Product Rule for EGF:
The binomial coefficient $\binom{n}{k}$ automatically counts the ways to partition $n$ labeled elements between the two substructures!
2. Interactive Recurrence Tree Explorer
The interactive simulation below renders the recursion tree for any divide-and-conquer parameters $a, b, f(n)$:
- Visual Depth Progression: Displays individual tree levels, node counts ($a^k$), subproblem dimensions ($n/b^k$), and local non-recursive overhead $a^k f(n/b^k)$.
- Dynamic Regime Classifier: Highlights whether the recurrence belongs to Case 1 (Leaf Dominant), Case 2 (Balanced), or Case 3 (Root Dominant), displaying the exact Master Theorem complexity bound.
Rigorous Tiered Solved Examination Problems
Step-by-step unskipped derivations, complete proofs, and verification across Foundational, Advanced, and Honors tiers.
- Solve the second-order linear homogeneous recurrence relation:
subject to the initial conditions $a_0 = 1, a_1 = 4$.
- Find the complete solution to the non-homogeneous recurrence relation:
with initial condition $b_0 = 5$.
1. Solving $a_n = 5 a_{n-1} - 6 a_{n-2}$
Step A: Characteristic Equation
Assume $a_n = r^n$:
Factoring:
The roots are distinct: $r_1 = 2$ and $r_2 = 3$.
Step B: General Homogeneous Solution
Step C: Apply Initial Conditions
- For $n = 0$:
- For $n = 1$:
From the first equation, $\alpha_1 = 1 - \alpha_2$. Substitute into the second:
Then $\alpha_1 = 1 - 2 = -1$.
Thus, the exact solution is:
2. Solving $b_n = 2 b_{n-1} + 3^n$
Step A: Homogeneous Solution
The homogeneous equation is $b_n - 2 b_{n-1} = 0$, giving characteristic equation $r - 2 = 0 \implies r = 2$.
Step B: Particular Solution
Since the driving term is $F(n) = 3^n$ and $\lambda = 3$ is not a root of the characteristic equation ($3 \ne 2$), we try:
Substitute into the recurrence:
Divide through by $3^{n-1}$:
Thus:
Step C: General Solution and Initial Condition
Using $b_0 = 5$:
Therefore, the unique solution is:
The Catalan numbers satisfy the non-linear recurrence:
- Define the ordinary generating function $C(x) = \sum_{n=0}^\infty C_n x^n$. Prove that $C(x)$ satisfies the algebraic equation $x C(x)^2 - C(x) + 1 = 0$.
- Solve this quadratic equation and justify mathematically why the negative square root branch must be chosen.
- Use the generalized binomial series expansion of $(1 - 4x)^{1/2}$ to extract the coefficient of $x^n$ and establish that:
1. Generating Function Equation
Let $C(x) = \sum_{n=0}^\infty C_n x^n$. The Cauchy product of $C(x)$ with itself is:
Multiplying by $x$:
Let $n = m + 1$. The sum runs from $n = 1$ to $\infty$:
By the recurrence relation, the bracketed inner sum is precisely $C_n$:
Rearranging terms yields the quadratic relation:
2. Solving the Quadratic and Branch Selection
Using the quadratic formula:
To select the correct branch, evaluate the limit as $x \to 0$: Since $C(x) = C_0 + C_1 x + \dots$, we must have $\lim_{x \to 0} C(x) = C_0 = 1$.
- If we chose the positive sign:
- Choosing the negative sign:
which matches $C_0 = 1$ perfectly!
Therefore, the generating function is:
3. Generalized Binomial Expansion and Coefficient Extraction
By Newton's generalized binomial theorem:
Let us compute $\binom{1/2}{k}$ for $k \ge 1$:
Expressing the double factorial in terms of standard factorials:
Thus:
Now multiply by $(-4)^k = (-1)^k 2^{2k}$:
Substitute back into the expression for $C(x)$:
Let $n = k - 1 \implies k = n + 1$:
Extracting the coefficient of $x^n$:
Consider the divide-and-conquer recurrence relation:
defined on powers of $b$ ($n = b^k$), with base case $T(1) = \Theta(1)$.
- Expand the recurrence into an explicit geometric tree summation across depth levels $j = 0, 1, \dots, \log_b n$.
- Prove Case 1: If $f(n) = O(n^{\log_b a - \epsilon})$ for $\epsilon > 0$, prove that $T(n) = \Theta(n^{\log_b a})$.
- Prove Case 2: If $f(n) = \Theta(n^{\log_b a})$, prove that $T(n) = \Theta(n^{\log_b a} \log n)$.
- Prove Case 3: If $f(n) = \Omega(n^{\log_b a + \epsilon})$ and $a f(n/b) \le c f(n)$ for $c < 1$, prove that $T(n) = \Theta(f(n))$.
1. Recursion Tree Summation
At level $j$ of the recursion tree:
- Number of subproblems $= a^j$.
- Size of each subproblem $= \frac{n}{b^j}$.
- Non-recursive combine work per subproblem $= f\left(\frac{n}{b^j}\right)$.
- Total work done at level $j$: $W_j = a^j f\left(\frac{n}{b^j}\right)$.
The tree reaches the leaves when $\frac{n}{b^k} = 1 \implies k = \log_b n$. The number of leaves is $a^k = a^{\log_b n} = n^{\log_b a}$. Summing across all levels:
2. Proof of Case 1: $f(n) = O(n^{\log_b a - \epsilon})$
Let $p = \log_b a$. We are given $f(n) \le C n^{p - \epsilon}$. Substitute this bound into the level sum:
Recall that $b^p = b^{\log_b a} = a$. Thus:
Therefore:
Since $b > 1$ and $\epsilon > 0$, the ratio $b^\epsilon > 1$. The sum is an increasing geometric series:
Multiplying by $C n^{p - \epsilon}$:
The leaf work $\Theta(n^{\log_b a})$ dominates the sum. Hence:
3. Proof of Case 2: $f(n) = \Theta(n^{\log_b a})$
Here $f(n) = \Theta(n^p)$. Then at each level $j$:
Since $b^p = a$, the ratio $\frac{a}{b^p} = 1$. Thus, every single level does identical work:
There are $k = \log_b n$ levels:
Adding the leaf work $\Theta(n^p)$, we obtain:
4. Proof of Case 3: Root Dominant with Regularity Condition
We are given $a f(n/b) \le c f(n)$ for some constant $c < 1$. Applying this inequality inductively:
Therefore, the sum over all levels is bounded by a convergent geometric series:
Since the $j=0$ term (the root) alone is $f(n)$, the sum is also $\Omega(f(n))$. Furthermore, since $f(n) = \Omega(n^{p + \epsilon})$, the root work $f(n)$ asymptotically dwarfs the leaf work $n^p$:
Thus: