Question

Consider the following recurrence relation:

T(n)=2T(n−1)+n2n for n>0,T(0)=1.T(n) = 2T(n - 1) + n 2^n \text{ for } n > 0, \quad T(0) = 1.

Which ONE of the following options is CORRECT?

Choose one option
Official answer and solution
Official answer
A
From
Official GATE 2025 answer key

Solution

Divide both sides of the recurrence by 2n2^n and telescope the resulting sum.

Dividing the recurrence T(n)=2T(n−1)+n2nT(n) = 2T(n-1) + n 2^n by 2n2^n yields:

T(n)2n=T(n−1)2n−1+n\frac{T(n)}{2^n} = \frac{T(n-1)}{2^{n-1}} + n

Let S(n)=T(n)2nS(n) = \frac{T(n)}{2^n} with S(0)=T(0)20=1S(0) = \frac{T(0)}{2^0} = 1. Unrolling the recurrence gives:

S(n)=S(0)+∑k=1nk=1+n(n+1)2=Θ(n2)S(n) = S(0) + \sum_{k=1}^{n} k = 1 + \frac{n(n+1)}{2} = \Theta(n^2)

Multiplying back by 2n2^n, we obtain:

T(n)=Θ(n22n)T(n) = \Theta(n^2 2^n)
Final answer

Option (A)

Common trap

Forgetting that nn terms of order Θ(k2n)\Theta(k 2^n) sum to Θ(n22n)\Theta(n^2 2^n) rather than Θ(n2n)\Theta(n 2^n).

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2025 Computer Science and Information Technology - Session 1 (CS1)
Question
20 of 65
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.