GATE / CS ARCHIVE

GATE CSE 2026 SET 2 / QUESTION 25

Solving four runtime recurrences

Algorithms · Asymptotic Analysis & Recurrences · Full GATE CSE 2026 Set 2 paper

GATE 2026 Set 2, Q25 1 mark · MSQ
Report issue

Asymptotic Analysis & Recurrences

Question 25, GATE 2026: All base cases are T(1)=1. Which recurrences give Θ(n)? A T(n)=T(n−1)+1; B T(n)=2T(n/2)+1; C T(n)=2T(n/2)+n; D T(n)=T(n−1)+n. For halving recurrences use powers of two or conventional rounding.
Tap to enlarge
Select all that apply
Answer & solution

Official answer: A, B

Givens and goal

All base cases are T(1)=1. Which recurrences give Θ(n)? A T(n)=T(n−1)+1; B T(n)=2T(n/2)+1; C T(n)=2T(n/2)+n; D T(n)=T(n−1)+n. For halving recurrences use powers of two or conventional rounding.

Approach

Unroll decrement recurrences and sum levels in divide-and-conquer trees.

Step-by-step solution

1. A makes n−1 unit increments above its base: T(n)=1+(n−1)=n. It is Θ(n).
2. For B, n=2h gives a full binary recursion tree with n leaves. The leaves contribute n; its n−1 internal nodes each contribute 1. Thus T(n)=2n−1=Θ(n).
3. For C, level j has 2j subproblems of size n/2j, so its nonrecursive work is 2j(n/2j)=n. There are log₂n internal levels and n units at the leaves. Therefore T(n)=n log₂n+n=Θ(n log n).
4. D unrolls into 1+2+…+n=n(n+1)/2=Θ(n²). Unlike A, its added work grows with the current input size.
5. Only A and B are linear. Matching recursion shape alone is insufficient: B and C have the same branching but different work per node.

Original paper, page 20 · Answer key