1. Gyanastra
  2. Algorithms
  3. Recurrence Relations and the Master Theorem
  4. Back Substitution Method (T(n) = 1 + T(n-1))
Free lesson, no account needed 6 min read 11 practice questions after it
Asked in past papers9 times
  • GATE CSE202620062004200319981990
  • ISRO201820172014

Algorithms · Recurrence Relations and the Master Theorem

Back Substitution Method (T(n) = 1 + T(n-1))

Overview

Back substitution solves a recurrence by repeatedly expanding it into itself until a pattern appears, then choosing the number of substitutions so the argument reaches the base condition.
It matters because it turns a recursive time recurrence such as T(n)=1+T(n−1)T(n) = 1 + T(n-1) into a closed-form complexity, here linear time.

Key concepts

  • Back substitution: A method for solving a recurrence relation: repeatedly substitute the recurrence into itself (replace T(n−1)T(n-1) by its own expansion, then T(n−2)T(n-2), and so on) until a pattern k+T(n−k)k + T(n-k) appears, then choose kk so that the argument hits the base condition, and evaluate.
  • Source of the recurrence: A recursive algorithm of the form
A(n):
    if n > 1:
        return A(n-1)      // plus some constant work (comparison / return)

If T(n)T(n) is the time taken by A(n)A(n), the time is a constant amount for the comparison plus the time to solve the problem on n−1n-1 inputs, giving T(n)=1+T(n−1)T(n) = 1 + T(n-1). The constant may be written as 1 or as cc; it makes no difference.

  • Anchor / base / stopping condition: The recurrence is valid only when n>1n > 1. nn starts large and decreases by 1 each time; when it reaches 1 the algorithm stops (it just does the comparison).
    This condition terminates the recursion and fixes the value of kk.

How it works

  1. Write the recurrence and generate successive equations by substituting n−1n-1, n−2n-2, ... in place of nn:
    • Equation 1: T(n)=1+T(n−1)T(n) = 1 + T(n-1)
    • Equation 2: T(n−1)=1+T(n−2)T(n-1) = 1 + T(n-2) (replace nn by n−1n-1)
    • Equation 3: T(n−2)=1+T(n−3)T(n-2) = 1 + T(n-3) (replace nn by n−2n-2)
  2. Substitute Equation 2 into Equation 1 (put the whole expression for T(n−1)T(n-1) in place of T(n−1)T(n-1)): T(n)=1+(1+T(n−2))=2+T(n−2)T(n) = 1 + (1 + T(n-2)) = 2 + T(n-2)
  3. Substitute Equation 3 in place of T(n−2)T(n-2): T(n)=2+(1+T(n−3))=3+T(n−3)T(n) = 2 + (1 + T(n-3)) = 3 + T(n-3)
  4. Continue the pattern; after kk substitutions: T(n)=k+T(n−k)T(n) = k + T(n-k)
  5. Find where to stop: the base condition is n=1n = 1.
  6. To eliminate T(n−k)T(n-k) we need T(1)T(1), i.e. n−k=1n - k = 1, which gives k=n−1k = n - 1.
  7. Put k=n−1k = n-1 into k+T(n−k)k + T(n-k): T(n)=(n−1)+T(n−(n−1))=(n−1)+T(1)T(n) = (n-1) + T(n - (n-1)) = (n-1) + T(1)
  8. Use the base value T(1)=1T(1) = 1: T(n)=(n−1)+1=nT(n) = (n-1) + 1 = n

So T(n)=nT(n) = n, i.e. T(n)=O(n)T(n) = O(n) (order of n). This whole procedure is called back substitution.

Summary of the method: (1) assume the time to solve an instance of size nn is T(n)T(n); (2) split the time into the constant comparison/return time plus T(n−1)T(n-1); (3) find the base condition (here n=1n = 1, where it returns 1); (4) keep back substituting until the pattern k+T(n−k)k + T(n-k) appears; (5) set n−kn-k equal to the base value and evaluate.

Formulas

  • Recurrence: T(n)=1+T(n−1)T(n) = 1 + T(n-1), valid for n>1n > 1

  • Base condition: T(1)=1T(1) = 1

  • General pattern after kk substitutions: T(n)=k+T(n−k)T(n) = k + T(n-k)

  • Stopping value: n−k=1⇒k=n−1n - k = 1 \Rightarrow k = n - 1

  • Final answer: T(n)=(n−1)+T(1)=(n−1)+1=n=O(n)T(n) = (n-1) + T(1) = (n-1) + 1 = n = O(n)

  • Here nn = input size, T(n)T(n) = time to solve an instance of size nn, kk = number of substitutions made, 1 = constant time for comparison/return.

Worked examples

Solve T(n)=1+T(n−1)T(n) = 1 + T(n-1), T(1)=1T(1) = 1:

StepSubstitution madeResult
1T(n)=1+T(n−1)T(n) = 1 + T(n-1)1+T(n−1)1 + T(n-1)
2T(n−1)=1+T(n−2)T(n-1) = 1 + T(n-2) put into step 11+1+T(n−2)=2+T(n−2)1 + 1 + T(n-2) = 2 + T(n-2)
3T(n−2)=1+T(n−3)T(n-2) = 1 + T(n-3) put into step 22+1+T(n−3)=3+T(n−3)2 + 1 + T(n-3) = 3 + T(n-3)
...continuek+T(n−k)k + T(n-k)
Finalk=n−1k = n-1(n−1)+T(1)=(n−1)+1=n(n-1) + T(1) = (n-1) + 1 = n

Answer: T(n)=n=O(n)T(n) = n = O(n).

Growth chart: Back Substitution Method (T(n) = 1 + T(n-1))
Figure. Back Substitution Method (T(n) = 1 + T(n-1))

Revision summary

  • Back substitution = expand the recurrence repeatedly, spot the pattern k+T(n−k)k + T(n-k), then substitute the kk that reaches the base case.
  • Always identify the base/anchor/stopping condition first — it decides the value of kk (n−k=1⇒k=n−1n-k = 1 \Rightarrow k = n-1 here).
  • The constant in the recurrence can be written as 1 or cc; it does not change the order of the answer.
  • T(n)=1+T(n−1)T(n) = 1 + T(n-1) with T(1)=1T(1) = 1 gives T(n)=nT(n) = n, i.e. Θ(n)\Theta(n) / O(n)O(n) — linear time.
  • The recurrence T(n)=1+T(n−1)T(n) = 1 + T(n-1) is valid only for n>1n > 1; the algorithm stops when nn reaches 1.

Previous-year exam insights

  • For a recurrence of the form T(n) = aT(n/b) + f(n) with a ≥ 1, b > 1, the Master Theorem compares f(n) with nlog⁡ban^{\log_b a}: if f(n)=O(n(log⁡baf(n) = O(n^(\log_{b} a − ε)) then T(n) = Θ(nlog⁡ba)\Theta(n^{\log_{b} a});
    if f(n) = Θ(nlog⁡ba)\Theta(n^{\log_{b} a}) then T(n) = Θ(nlog⁡balog⁡n)\Theta(n^{\log_{b} a} \log n);
    if f(n) = Ω(nlog⁡ba+εn^{\log_b a + ε}) and the regularity condition a·f(n/b) ≤ c·f(n) holds for some c < 1, then T(n) = Θ(f(n))\Theta(f(n)).
    Asked inGATE 2006GATE 2026
  • For subtract-and-conquer recurrences T(n) = aT(n−b) + f(n) with constants a ≥ 1, b > 0 and polynomial f: when a > 1 the solution is exponential, Θ(an/b)\Theta(a^{n/b});
    when a = 1 it is Θ(n⋅f(n))\Theta(n\cdot f(n));
    in particular T(n) = T(n−1) + c is Θ(n)\Theta(n) and T(n) = 2T(n−1) + c is Θ(2n)\Theta(2^{n}).
    Asked inGATE 2004ISRO 2017ISRO 2014
  • A recurrence with a decreasing argument and constant extra work per level, such as T(n) = T(n−1) + 1 with T(1) = 1, always yields linear Θ(n)\Theta(n) time;
    the same Θ(n)\Theta(n) holds for any T(n) = T(n−1) + c with constant c > 0.
    Asked inGATE 2026ISRO 2014
  • When a recurrence has the form T(n) = T(n−1) + T(n−2) − T(n−3) (or any linear recurrence with constant coefficients), the order depends on the initial conditions: the characteristic roots determine whether the solution is constant, polynomial or exponential, so the base values must be checked before concluding the order.
    Asked inISRO 2018
  • For recurrences like T(n) = T(√n) + c, substitute m = log⁡n\log n to get S(m) = S(m/2) + c, giving T(n) = Θ(log⁡log⁡n)\Theta(\log\log n);
    similarly T(n) = 2T(√n) + c gives Θ(log⁡n)\Theta(\log n).
    Asked inGATE 2006
  • Summations useful in back substitution: ∑i=1n\sum_{i=1}^{n} 1 = n, ∑i=1n\sum_{i=1}^{n} i = n(n+1)/2 = Θ(n²), ∑i=0n\sum_{i=0}^{n} 2i=2n+1−12^{i} = 2^{n+1} - 1 = Θ(2n)\Theta(2^{n}), and ∑i=1n\sum_{i=1}^{n} 1/i = Θ(log⁡n)\Theta(\log n).
    Asked inGATE 2003GATE 2004
Pages 1–2 of 2