Generate diverse GATE-level questions covering solving recurrences using substitution, recursion tree, and Master Theorem, including edge cases and complexity analysis.
Concept summary for GATE CSE 2027 · 64 practice questions available
📘 Recurrence Relations – Concept Summary
1. Fundamental Definitions and Classification
In the domain of GATE CSE, recurrence relations serve as the definitive mathematical tool for quantifying the asymptotic behavior of recursive algorithms. To analyze any recursive procedure, we must bridge the gap between code logic and mathematical modeling by defining the total work T(n) in terms of smaller instances of the same problem.
A recurrence relation is an equation that expresses a sequence term as a function of its preceding terms. For these models to be computationally valid, they must include a base condition-a constant-time termination point (e.g., T(1)=Θ(1)) that prevents infinite recursion.
Classification Matrix:
| Category | Logic | Example |
| :--- | :--- | :--- |
| Divide-and-Conquer | Problem split into a subproblems of size n/b. | T(n)=2T(n/2)+n |
| Linear/Decremental | Size reduces by a constant amount (e.g., n−1). | T(n)=T(n−1)+n |
| Homogeneous | The difference between terms equals zero. | an−3an−1=0 |
| Non-Homogeneous | The difference between terms is a function f(n)=0. | an−2an−1=3n |
2. Core Idea: From Recursion to Mathematical Representation
Recursive decomposition is a strategic design choice where a complex problem is reduced to subproblems of the same type. The total time complexity T(n) is the sum of the time spent in recursive calls and the work required for the "divide and combine" steps, denoted as f(n).
Mathematically, this is represented as T(n)=aT(n/b)+f(n). Here, a represents the branching factor (number of recursive calls), and n/b represents the reduced input size. A recursion tree provides a visual trace of this flow, where each node captures the cost f(n) at that specific level of recursion. Understanding this structural growth is paramount to identifying whether an algorithm will scale linearly, logarithmically, or exponentially.
3. Key Properties for GATE Analysis
Identifying structural properties allows a candidate to apply rapid elimination strategies in Multiple Select Questions (MSQs). As a technical architect, you must evaluate the following:
Branching Factor (a): Dictates the tree's width. If a>1, the tree expands, potentially leading to polynomial or exponential complexity.
Base Case Necessity: Any recurrence without a valid base case is mathematically divergent and computationally invalid.
Work per Level (f(n)): If f(n) grows faster than the number of leaves, the root dominates. If the leaves grow faster, the complexity is Θ(nlogba).
Senior Educator's Strategy: Immediately discard options where the branching factor a implies exponential growth (e.g., a=2,b=1) but the proposed complexity is polynomial. Conversely, for divide-and-conquer, if f(n) is a lower-order polynomial than the leaf count, the leaves always dictate the bound.
4. Formalizing Recurrence Relations from Algorithms
Correct formulation is the prerequisite for any solution. A common pitfall is neglecting the f(n) cost, such as the linear-time "Merge" step in Merge Sort.
Step-by-Step Derivation: Merge Sort
Divide: Splitting the array takes Θ(1).
Recurse: The algorithm calls itself twice on halves of the input →2T(n/2).
Combine: The Merge procedure compares n elements →Θ(n).
Verification: For c≥1, T(n)≤cnlogn. The proof holds.
Method Properties:
Pros: High precision; solves non-standard forms.
Cons: Requires a correct initial guess; algebraically intensive.
6. Iteration and Expansion Method
This method "unrolls" the recurrence to reveal a summation pattern, ideal for linear recurrences where the reduction is additive. Example: T(n)=T(n−1)+n with T(0)=0 T(n)=[T(n−2)+(n−1)]+n T(n)=[T(n−3)+(n−2)+(n−1)]+n
General Form: ∑i=1ni=2n(n+1)
Complexity: Θ(n2)
7. The Recursion Tree Method
The recursion tree is the visual bridge for unbalanced or multi-term recurrences.
Unbalanced Tree Height: For T(n)=T(n/4)+T(n/2)+cn2, the branches have different lengths. The longest path to a leaf is log2n (via the n/2 branch).
Total Cost: Summing work per level gives cn2(1+5/16+25/256+…). Since the ratio r=5/16<1, the geometric series converges, meaning the root dominates. Thus, T(n)=Θ(n2).
8. Master Theorem: Standard and Advanced Versions
The Master Theorem is the primary shortcut for T(n)=aT(n/b)+Θ(nklogpn).
Master Theorem Case Summary:
| Compare a with bk | Condition | Resulting Θ(n) |
| :--- | :--- | :--- |
| a>bk | Root work is less than leaf work | Θ(nlogba) |
| a=bk | Work is balanced | (a) p>−1: Θ(nklogp+1n) <br> (b) p=−1: Θ(nkloglogn) <br> (c) p<−1: Θ(nk) |
| a<bk | Root work dominates | (a) p≥0: Θ(nklogpn) <br> (b) p<0: Θ(nk) |
Note: If f(n) is not polynomial (e.g., 2n), Master Theorem fails.
9. Advanced Recurrence Concepts (Rank-Breakers)
Variable Transformation:
For T(n)=nT(n)+n (GATE 2024):
Divide by n: nT(n)=nT(n)+1.
Let S(n)=nT(n), so S(n)=S(n)+1.
Let n=2m: S(2m)=S(2m/2)+1. Let G(m)=S(2m)⟹G(m)=G(m/2)+1.
By Master Theorem, G(m)=Θ(logm).
Substitute back: m=logn⟹S(n)=Θ(loglogn).
Finally, T(n)=n⋅S(n)=Θ(nloglogn).
Generating Functions (6-Step Procedure):
Used for recurrences like Fibonacci (an=an−1+an−2):
Rewrite the relation as an equation (e.g., an−an−1−an−2=0).
Multiply by xn and sum from n=2 to ∞.
Define G(x)=∑n=0∞anxn and substitute into the equation to find G(x) in terms of x.
Decompose G(x) using partial fractions (for Fibonacci, roots are 21±5).
Express G(x) as a sum of geometric series.
Extract an as the coefficient of xn.
10. Complexity Analysis and Recursive Stack
Recursive algorithms incur overhead in the System Stack.
Non-Polynomial f(n) Trap: T(n)=2T(n/2)+2n. Master Theorem is inapplicable here because f(n) must be polynomial relative to nlogba. Use the Iteration Method.
MSQ Trap: T(n)=2T(n/2)+logn. Students often pick Θ(logn) or Θ(nlogn). Correct answer: a=2,b=2,k=0→a>bk (Case 1) ⟹Result:Θ(n).
Variable Trap: In T(n)=2T(n/2)+n/logn, Master Theorem fails (Case 2 gap).