Consider the recurrence equation
$T(n) =\begin{cases} 2T(n-1), & \text{if }n>0 \\ 1, & \text{otherwise} \end{cases}$
Then $T(n)$ is (in $big\, O$ order)
it should be O(2n) only, if it T(0) = 0, then it would be O(1)
Surely O(2n)
$T(n)=2T(n-1)$
$T(n)=2[2T(n-2)]=2^{2}T(n-2)$
$T(n)=2^{2}[2T(n-3)]= 2^{3}T(n-3)$
$T(n)=2^{k}T(n-k)$
$n-k=0, \ n=k,\ T(0)=1$
$T(n)=2^{n}$
Hence option B) is correct
papujimmy no you are a little wrong that extra amount of work you are mentioning is not done in this recurrence, if it is not done or that work is less as compared to recurrence then that is not considered while calculating complexity.
64.3k questions
77.9k answers
244k comments
80.0k users