Answer: A
We can solve this recurrence relation using two approaches: a quick verification method for the exam, and a formal analytical derivation.
Method 1: Quick Verification
Let us compute the first few terms of the sequence using the recurrence relation:
- T(1)=1
- T(2)=2T(1)+2=2(1)+2=4
Now, substitute n=2 into the given options:
- Option A: 22+1−2−2=8−4=4 (Matches)
- Option B: 22−2=2 (Incorrect)
- Option C: 22+1−2(2)−2=8−4−2=2 (Incorrect)
- Option D: 22+2=6 (Incorrect)
Method 2: Analytical Derivation
Expanding the recurrence relation by substitution:
T(n)=2T(n−1)+n=2[2T(n−2)+(n−1)]+n=22T(n−2)+2(n−1)+n=22[2T(n−3)+(n−2)]+2(n−1)+n=23T(n−3)+22(n−2)+2(n−1)+n ⋮=2n−1T(1)+i=0∑n−22i(n−i)
Since T(1)=1, we have:
T(n)=2n−1+ni=0∑n−22i−i=0∑n−2i2i
Using standard summation formulas for geometric and arithmetico-geometric series:
- ∑i=0n−22i=2n−1−1
- ∑i=0n−2i2i=(n−3)2n−1+2
Substituting these back into the equation:
T(n)=2n−1+n(2n−1−1)−[(n−3)2n−1+2]=2n−1+n2n−1−n−n2n−1+3⋅2n−1−2=4⋅2n−1−n−2=2n+1−n−2