← 📈 Asymptotic Analysis & Recurrences
Subtopic 3 of 4

1.3Solving recurrences

The idea

A recurrence expresses the cost of a recursive algorithm in terms of smaller inputs. Solve it by guessing and checking, or by summing the work in each level of the recursion tree.

Think of it like this: A chain of messengers: each one hands part of the work to others, and you add up what everyone did.

Why it exists

T(n) = T(n − 1) + n, T(√n) + 1 and unequal splits are not covered by the Master theorem, but they show up in GATE.

How it works

  1. Write the recurrence, with a base case T(1) = 1.
  2. Expand a few levels or draw the recursion tree.
  3. Add the work in each level and the number of levels.
  4. Confirm by induction or by checking that T(n)/guess settles near a constant.

Worked example: T(n) = T(n/3) + T(2n/3) + n

Every level of the tree costs at most n, and the longest path shrinks by 2/3 each step, so there are log_{3/2} n levels: Θ(n log n).

Now play with it

  • →Pick each recurrence and watch the ratio column settle.
  • →Try T(n) = T(n − 1) + T(n − 2) + 1: the ratio against 1.618ⁿ is constant.
nT(n)guess n log nT(n) / guess
1680641.250
2562,3042,0481.125
4,09653,24849,1521.083
65,53611,14,11210,48,5761.063
10,48,5762,20,20,0962,09,71,5201.050

If the last column settles near a constant, the guess is the right Θ. If it keeps growing, the guess is too small; if it keeps shrinking, too large. T(√n) + 1 reaches log log n because each step squares the shrinking.

Check yourself

T(n) = T(√n) + 1 gives

Remember: T(n − 1) + n = n²; T(n/2) + 1 = log n; T(√n) + 1 = log log n; 2T(n − 1) + 1 = 2ⁿ.
Exam notes (the dense version)

A recursive algorithm gives a recurrence T(n). Three tools: substitution (guess then prove by induction), recursion tree (sum the work per level) and the Master theorem. Common ones: T(n) = T(n − 1) + n → Θ(n²); T(n) = T(n − 1) + 1 → Θ(n); T(n) = 2T(n − 1) + 1 → Θ(2ⁿ); T(n) = T(n/2) + 1 → Θ(log n); T(n) = T(√n) + 1 → Θ(log log n); T(n) = T(n/3) + T(2n/3) + n → Θ(n log n).

Previous year questions: Asymptotic Analysis & Recurrences (16)

PYQs are grouped by topic, so this is the full set for Asymptotic Analysis & Recurrences; try the ones that match this subtopic. Open all 16 on the topic page.