Recurrence Relations and Growth Rates
Solving recurrence relations, running times, and big-O notation
The topics of this chapter follow the course calendar and Kameron Decker Harris’s Fall 2026 lecture notes, which name recurrence relations and order of growth as the topics after recursive algorithms. One idea comes from those notes: the running time of a recursive function is the running time of its recursive call plus the work outside it.
Everything else is new: the exercises, the examples, the algorithms pal_loop, table and pairs, the Racket functions, the theorems and their proofs. The algorithms pal and root come from earlier chapters of these notes.
1 Recurrence relations
2 Solving recurrence relations by iteration
3 Checking a closed form by induction
Proof. We use induction (Definition: Proof by induction), following Remark: The shape of a proof by induction with \(n_0 = 0\). Let \(P(n)\) be the equation \(b_n = n \cdot 2^n\).
Base case. \(b_0 = 0 = 0 \cdot 2^0\).
Inductive step. Let \(k \ge 0\) be an integer, and suppose \(P(k)\): \(b_k = k \cdot 2^k\). The goal \(P(k + 1)\) is \(b_{k + 1} = (k + 1) \cdot 2^{k + 1}\). Since \(k + 1 \ge 1\), the recurrence relation gives \(b_{k + 1}\), and
\[ \begin{aligned} b_{k + 1} &= 2 b_k + 2^{k + 1} && \text{(recurrence relation)} \\&= 2 \cdot k \cdot 2^k + 2^{k + 1} && \text{(induction hypothesis)} \\&= k \cdot 2^{k + 1} + 2^{k + 1} \\&= (k + 1) \cdot 2^{k + 1}. \end{aligned} \]
So \(P(k + 1)\) holds, and by induction \(b_n = n \cdot 2^n\) for every non-negative integer \(n\).
Proof. We use induction (Definition: Proof by induction), following Remark: The shape of a proof by induction with \(n_0 = 0\). Let \(P(n)\) be the equation \(e_n = 3^{n+1} - 2^{n+1}\).
Base case. \(e_0 = 1 = 3 - 2 = 3^1 - 2^1\).
Inductive step. Let \(k \ge 0\) be an integer, and suppose \(P(k)\): \(e_k = 3^{k+1} - 2^{k+1}\). The goal \(P(k + 1)\) is \(e_{k + 1} = 3^{k+2} - 2^{k+2}\). Since \(k + 1 \ge 1\), the recurrence relation gives \(e_{k + 1}\), and
\[ \begin{aligned} e_{k + 1} &= 3 e_k + 2^{k + 1} && \text{(recurrence relation)} \\&= 3 \mathopen{}\left(3^{k+1} - 2^{k+1}\right)\mathclose{} + 2^{k + 1} && \text{(induction hypothesis)} \\&= 3^{k+2} - 3 \cdot 2^{k+1} + 2^{k + 1} \\&= 3^{k+2} - 2 \cdot 2^{k+1} \\&= 3^{k+2} - 2^{k+2}. \end{aligned} \]
So \(P(k + 1)\) holds, and by induction \(e_n = 3^{n+1} - 2^{n+1}\) for every non-negative integer \(n\).
4 Running times of recursive algorithms
Proof. The recurrence relation uses \(T(n - 2)\), not \(T(n - 1)\), so we use strong induction (Definition: Proof by strong induction). Let \(n \ge 0\) be an integer, and suppose \(T(m) = \mathopen{}\left\lfloor m / 2\right\rfloor\mathclose{} + 1\) for every integer \(m\) with \(0 \le m < n\).
If \(n \le 1\), then \(T(n) = 1 = 0 + 1 = \mathopen{}\left\lfloor n / 2\right\rfloor\mathclose{} + 1\).
If \(n \ge 2\), then \(0 \le n - 2 < n\), and \(\mathopen{}\left\lfloor(n - 2) / 2\right\rfloor\mathclose{} = \mathopen{}\left\lfloor n / 2 - 1\right\rfloor\mathclose{} = \mathopen{}\left\lfloor n / 2\right\rfloor\mathclose{} - 1\), since subtracting the integer 1 from a real number subtracts 1 from its floor. So
\[ \begin{aligned} T(n) &= T(n - 2) + 1 && \text{(recurrence relation)} \\&= \mathopen{}\left\lfloor(n - 2) / 2\right\rfloor\mathclose{} + 1 + 1 && \text{(strong induction hypothesis)} \\&= \mathopen{}\left\lfloor n / 2\right\rfloor\mathclose{} - 1 + 2 \\&= \mathopen{}\left\lfloor n / 2\right\rfloor\mathclose{} + 1. \end{aligned} \]
So the formula holds for \(n\), and by strong induction it holds for every non-negative integer \(n\).
5 Two recursive calls
Proof. Let \(B(n)\) be the number of calls of (dm 0) among the calls that (dm n) makes. Every call of (dm n) does the same work, so \(B(n)\) depends only on \(n\). When \(n \ge 1\), (dm n) is not itself a call of (dm 0), and it calls (dm (- n 1)) twice, as in Solution 5, so
\[ B(0) = 1, \qquad B(n) = 2 B(n - 1) \quad\text{for } n \ge 1. \]
We use induction (Definition: Proof by induction), following Remark: The shape of a proof by induction with \(n_0 = 0\), with \(P(n)\) the equation \(B(n) = 2^n\).
Base case. \(B(0) = 1 = 2^0\).
Inductive step. Let \(k \ge 0\) be an integer, and suppose \(B(k) = 2^k\). Then \(B(k + 1) = 2 B(k) = 2 \cdot 2^k = 2^{k + 1}\).
So \(B(n) = 2^n\) for every non-negative integer \(n\). Each of these calls is a step, so (dm n) takes at least \(2^n\) steps.
6 Asymptotic notation
Proof. Let \(c_1\), \(N_1\) be witnesses (Definition 6) for \(f(n) = O(h(n))\), and \(c_2\), \(N_2\) witnesses for \(g(n) = O(h(n))\). Let \(N\) be the larger of \(N_1\) and \(N_2\). The triangle inequality (Wikipedia contributors 2026g) says that \(\mathopen{}\left|x + y\right|\mathclose{} \le \mathopen{}\left|x\right|\mathclose{} + \mathopen{}\left|y\right|\mathclose{}\) for all real numbers \(x\) and \(y\). For every natural number \(n \ge N\), both \(n \ge N_1\) and \(n \ge N_2\) hold, so
\[ \begin{aligned} \mathopen{}\left|f(n) + g(n)\right|\mathclose{} &\le \mathopen{}\left|f(n)\right|\mathclose{} + \mathopen{}\left|g(n)\right|\mathclose{} && \text{(triangle inequality)} \\&\le c_1 \mathopen{}\left|h(n)\right|\mathclose{} + c_2 \mathopen{}\left|h(n)\right|\mathclose{} && \text{(} n \ge N_1 \text{ and } n \ge N_2 \text{)} \\&= (c_1 + c_2) \mathopen{}\left|h(n)\right|\mathclose{}. \end{aligned} \]
So \(c_1 + c_2\) and \(N\) are witnesses for \(f(n) + g(n) = O(h(n))\).
7 Disproving a bound
8 Common growth rates
Proof. We use that \(2^y < 2^z\) for real numbers \(y < z\). Let \(n \ge 4\) be a natural number, and let \(y = \log_2 n\), so that \(2^y = n\).
\(1 \le \log_2 n\). If \(y < 1\), then \(n = 2^y < 2^1 = 2\), which is false.
\(\log_2 n < n\). First, \(m < 2^m\) for every natural number \(m\), by induction (Definition: Proof by induction).
Base case. \(1 < 2 = 2^1\).
Inductive step. If \(k < 2^k\) for an integer \(k \ge 1\), then \(k + 1 \le 2^k < 2^k + 2^k = 2^{k + 1}\).
So \(n < 2^n\). If \(y \ge n\), then \(n = 2^y \ge 2^n\), which is false.
\(n \le n \log_2 n\) and \(n \log_2 n < n^2\). Multiply \(1 \le \log_2 n < n\) by \(n > 0\).
\(n^2 \le 2^n\). This is Example: An induction that starts at 4, since \(n \ge 4\).
\(2^n \le n!\). By induction, following Remark: The shape of a proof by induction with \(n_0 = 4\).
Base case. \(2^4 = 16 \le 24 = 4!\).
Inductive step. If \(2^k \le k!\) for an integer \(k \ge 4\), then
\[ \begin{aligned} 2^{k + 1} &= 2 \cdot 2^k \\&\le 2 \cdot k! && \text{(induction hypothesis)} \\&< (k + 1) \cdot k! && \text{(} 2 < k + 1 \text{)} \\&= (k + 1)!. \end{aligned} \]