0

What would be the complexity of the following recurrence?

$$T(n) = 2T(n-1)$$

Daniel
  • 72
  • 8
Josh3248
  • 103
  • 1
  • 1
  • 5

2 Answers2

1

Note: The original version of the post included the initial values $T(0) = 0$ and $T(1) = 1$.

If $T(n) = 2T(n-1)$ for all $n > C$ then, as you can prove by induction, $$ T(n) = 2^{n-C} T(C). $$ In particular, in your case $T(n) = 2^{n-1}$. Note that given your initial values, the recurrence $T(n) = 2T(n-1)$ cannot hold for $n=1$; presumably it holds for all larger $n$.

You are asking for the complexity of the recurrence. Recurrences have no such thing as complexity. A recurrence might describe the running time of an algorithm, and then its solution is the time complexity of the algorithm. But a recurrence can describe any number of things, or even be completely abstract.

Yuval Filmus
  • 276,994
  • 27
  • 311
  • 503
0

i don't know what do you mean about complexity of reccurence but if you want to find the closed form you can use the backward substitution method:
$T(n) = 2T(n-1)$
and then expand the $T(n-1)$:
$T(n) = 2(2T(n-2))$
and after that expand $T(n-2)$:
$T(n) = 2(2(2T(n-3)))$
...
$T(n) = 2^nT(0) $
and if you have $T(0) = C$ as a base case, your closed form would be: $T(n) = C2^n$

Daniel
  • 72
  • 8
  • What if $T(0) = 0$, does that make $T(n)=0$ and therefore $T(n)=O(1)$ instead of $T(n)=O(2^n)$? This is what confuses me the most – Josh3248 Mar 29 '18 at 11:22
  • in practice, when you have a base case like: $T(0) = 0$, you mean the cost of the algorithm with the size of ZERO is ZERO and after that for the size of ONE is ZERO too. because the closed form constructed by the base case and the equation doesn't have a heterogeneous part, it is strictly based on the base case and i think it doesn't true because of the wrong base case value. – Daniel Mar 29 '18 at 14:20