0

I'm trying to solve this time complexity: $T(n) = 2T(n-2) + n$, but having some challenges addressing the $(-2)$ component. Any insights on this complexity?

Ended up with a section $[2^2\cdot1 + 2^3\cdot2 + 2^4\cdot3 + \ldots + 2^{k+1}\cdot k$. Does it follow any existing number series?

D.W.
  • 159,275
  • 20
  • 227
  • 470
cch
  • 1

1 Answers1

0

Hint:

Set $n=2m$ and the recurrence turns to

$$T(2m)=2T(2(m-1))+2m$$ which can be written like a usual recurrence

$$S(m)=2S(m-1)+2m.$$

After solving for $S(m)$, you get $T(n)=S(\frac n2)$.


As the recurrence only involves numbers of the same parity, there are in fact two independent sequences, that correspond to the initial values $T(0)$ and $T(1)$.


The $S$ recurrence can be solved by variation of the constant, setting

$$S(m)=2^mR(m)$$ with implies

$$2^mR(m)=2^mR(m-1)+2m$$ or $$R(m)=R(m-1)+2m2^{-m}$$ which is solved by a mere summation.