3.1.8 · D1Complexity Analysis

Foundations — Substitution method for recurrences

2,040 words9 min readBack to topic

This page is the toolbox. The parent note swings the tools; here we forge them one at a time. If a smart 12-year-old read the parent and stumbled on a symbol, the answer lives below.


0. What even is a "running time"?

Before any symbol, one picture. When you run a program on an input, it does some number of basic steps (a comparison, an addition, a swap). More input usually means more steps.

Figure — Substitution method for recurrences

Why the topic needs it: the whole game is to find a simple formula for . Right now is a black box — we only know how it relates to itself, which is the next idea.


1. A recurrence — a function that describes itself

Let us name every piece of that equation, because the parent uses the general shape constantly.

Figure — Substitution method for recurrences

Why the topic needs it: the substitution method exists only to turn a self-describing into a plain formula you can read at a glance.


2. The tools hiding inside the algebra

2a. The logarithm

The recurrence keeps halving. "How many times can I halve before I reach ?" — that question has a name.

The parent uses one algebra fact about logs. Here it is, earned:

Figure — Substitution method for recurrences

Why the topic needs it: the target bound is a log; you cannot manipulate it without the halving picture and the subtraction identity.


2b. Big-O, Big-Ω, Big-Θ — the shape of growth

We never prove equals an exact formula; we bound it. Three symbols express "how fast does it grow, ignoring constants and small ."

Figure — Substitution method for recurrences

Why the topic needs it: the substitution method's entire output is "" — an statement. Without and the proof has no target and no base to stand on.


2c. Mathematical induction — the logical engine

The substitution method is induction wearing a costume (see Mathematical Induction).

Why the topic needs it: "prove by induction" is literally step 2 of the method. The base case, the IH, and the single- rule all come straight from here.


2d. Two habits of algebra: substitute and absorb

Why the topic needs it: these are the middle two letters of the parent's mnemonic G-A-S-A-B (Guess, Assume, Substitute, Absorb, Base). They are the actual moves of the proof.


How it all feeds the topic

Input size n

Running time T of n

Recurrence T of n = a T of n over b + h of n

Logarithm log n = halving count

Target bound O of n log n

Big-O Big-Omega Big-Theta with constant c and n0

Mathematical Induction base plus step

Substitution method

Inductive hypothesis for smaller n

Substitute the guess

Absorb residual le 0


Equipment checklist

Cover the right side and answer aloud; then reveal.

What does mean in one sentence?
The number of basic steps the program takes on an input of size .
What is a recurrence?
An equation that defines using of smaller inputs plus extra local work.
In , what are , , and ?
= number of sub-jobs, = shrink factor (sub-job size ), = extra local cost.
What real question does answer?
How many times you must halve to reach .
State the identity used to split .
, because log turns division into subtraction and .
Why can't the base case start at for an bound?
, so at and can't bound a positive .
What do , , mean?
Upper bound, lower bound, and both-at-once (tight) bound on growth, ignoring constants.
What are and ?
= fixed positive multiplier you choose once; = smallest input size from which the bound must hold.
State the two parts of a proof by induction.
Base case (prove directly) and inductive step (assume IH for smaller inputs, prove ).
What is the inductive hypothesis in this method?
The guess assumed for all , especially .
Why is substituting the IH's bound legal for an upper bound?
Replacing by something it can only enlarge the right side, so survives.
What does "absorb the residual" require?
The leftover term must be with a single fixed , so it only helps the inequality.

Connections