Solving the Recurrence by Substitution Method
A recurrence is a common way to describe the running time of recursive or incremental algorithms. In this problem, the number of basic operations is defined by
This is a decrease-by-one recurrence: each step reduces the problem size by 1 and adds a linear amount of work, namely .2 The substitution method solves it by repeatedly replacing the smaller term with its own recurrence until the base case is reached.2
The key idea is that the recurrence unfolds into a sum of the first natural numbers, which has closed form
Therefore, we should expect quadratic growth, i.e. Theta notation .2
Footnotes
-
Time Complexity Analysis of Recursive Functions - GeeksforGeeks - Overview of recurrence-solving methods, including substitution. ↩ ↩2
-
SolvingRecurrences - Yale University - Notes explaining asymptotic solutions and the form . ↩ ↩2
-
Easy: Solve T(n)=T(n-1)+n by Iteration Method - Stack Overflow - Shows repeated expansion pattern leading to the summation. ↩
-
2.1.2 Recurrence Relation (T(n)= T(n-1) + n) #2 - YouTube - Demonstrates expansion of this exact recurrence and concludes quadratic growth. ↩
Substitution Method to Solve Recurrence Relation of Time
Core Observation
Because each recursive expansion adds the next integer, the recurrence accumulates the sum , which grows quadratically.2
Footnotes
-
Time Complexity Analysis of Recursive Functions - GeeksforGeeks - Overview of recurrence-solving methods, including substitution. ↩
-
2.1.2 Recurrence Relation (T(n)= T(n-1) + n) #2 - YouTube - Demonstrates expansion of this exact recurrence and concludes quadratic growth. ↩
Solving $T(n)=T(n-1)+n$ Using Substitution
- 1Step 1
Start with and the base case .
Footnotes
-
Time Complexity Analysis of Recursive Functions - GeeksforGeeks - Overview of recurrence-solving methods, including substitution. ↩
-
- 2Step 2
Replace using the same rule: . Then .2
Footnotes
-
Time Complexity Analysis of Recursive Functions - GeeksforGeeks - Overview of recurrence-solving methods, including substitution. ↩
-
Easy: Solve T(n)=T(n-1)+n by Iteration Method - Stack Overflow - Shows repeated expansion pattern leading to the summation. ↩
-
- 3Step 3
Expand again: , so . A pattern now appears.2
Footnotes
-
Time Complexity Analysis of Recursive Functions - GeeksforGeeks - Overview of recurrence-solving methods, including substitution. ↩
-
Easy: Solve T(n)=T(n-1)+n by Iteration Method - Stack Overflow - Shows repeated expansion pattern leading to the summation. ↩
-
- 4Step 4
After expansions, . Equivalently, .
Footnotes
-
Easy: Solve T(n)=T(n-1)+n by Iteration Method - Stack Overflow - Shows repeated expansion pattern leading to the summation. ↩
-
- 5Step 5
Set , so . Then the recurrence becomes .
Footnotes
-
Easy: Solve T(n)=T(n-1)+n by Iteration Method - Stack Overflow - Shows repeated expansion pattern leading to the summation. ↩
-
- 6Step 6
Footnotes
-
Time Complexity Analysis of Recursive Functions - GeeksforGeeks - Overview of recurrence-solving methods, including substitution. ↩
-
- 7Step 7
The sum of the first natural numbers is . Therefore .
Footnotes
-
2.1.2 Recurrence Relation (T(n)= T(n-1) + n) #2 - YouTube - Demonstrates expansion of this exact recurrence and concludes quadratic growth. ↩
-
- 8Step 8
The dominant term is , so the time complexity is .2
Footnotes
-
SolvingRecurrences - Yale University - Notes explaining asymptotic solutions and the form . ↩
-
2.1.2 Recurrence Relation (T(n)= T(n-1) + n) #2 - YouTube - Demonstrates expansion of this exact recurrence and concludes quadratic growth. ↩
-
Closed-Form Derivation
Using back substitution, we obtain
Since ,
Now apply the standard summation formula:
Hence,
Expanding,
The dominant term is , so
This agrees with the general principle that recurrences of the form accumulate the total sum of over smaller inputs.2
Footnotes
-
SolvingRecurrences - Yale University - Notes explaining asymptotic solutions and the form . ↩
-
Time Complexity Analysis of Recursive functions using Recurrence - UCF PDF - Academic notes on solving decrease-by-one recurrences through repeated substitution. ↩
Growth of
Sample values illustrating quadratic growth
Why the Complexity is
In asymptotic analysis, constants and lower-order terms are ignored. For
the term dominates as grows large. Therefore,
This means:
- it is not merely an upper bound like ,
- it is also a matching lower bound,
- so the growth rate is tightly quadratic.2
A useful intuition is that the recurrence adds a cost of about at the top level, then , then , and so on down to . That staircase-shaped accumulation produces an area proportional to .2
Footnotes
-
SolvingRecurrences - Yale University - Notes explaining asymptotic solutions and the form . ↩
-
2.1.2 Recurrence Relation (T(n)= T(n-1) + n) #2 - YouTube - Demonstrates expansion of this exact recurrence and concludes quadratic growth. ↩
-
Time Complexity Analysis of Recursive Functions - GeeksforGeeks - Overview of recurrence-solving methods, including substitution. ↩
-
Easy: Solve T(n)=T(n-1)+n by Iteration Method - Stack Overflow - Shows repeated expansion pattern leading to the summation. ↩
Exam Technique
For recurrences of the form , try expanding until the base case and then convert the result into a summation. This often reveals the closed form quickly.
Footnotes
-
Time Complexity Analysis of Recursive functions using Recurrence - UCF PDF - Academic notes on solving decrease-by-one recurrences through repeated substitution. ↩
1T(n)=T(n-1)+n 2 =T(n-2)+(n-1)+n 3 =...=T(1)+2+3+...+n 4 =1+2+3+...+n 5 =n(n+1)/2 6Therefore, T(n)=Θ(n^2).
Common Questions and Pitfalls
Common Mistake
Do not stop at ; that misses the decreasing terms . The correct expansion produces a sum, not just repeated copies of .
Footnotes
-
Easy: Solve T(n)=T(n-1)+n by Iteration Method - Stack Overflow - Shows repeated expansion pattern leading to the summation. ↩
Final Answer
The recurrence
solves to
Therefore, the algorithm performs a quadratic number of basic operations, and its time complexity is
Knowledge Check
After one substitution, what does become?
Explore Related Topics
Mastering Recurrence Relations: The Substitution Method
The lesson shows how to solve the classic recurrence with the substitution method, using a recursion‑tree intuition to guess an bound and then proving it by induction.
- Each level of the recursion tree costs , and there are levels → total .
- Inductive hypothesis: for , which simplifies to in the induction step.
- The base case must start at (e.g., ) because is false.
- Substitution offers rigorous proof, while recursion trees give quick guesses; the Master Theorem confirms .
Quick Sort Algorithm and Its Best-, Worst-, and Average-Case Time Complexities
