in Algorithms recategorized by
1,570 views
0 votes
0 votes

For the given recurrence equation

$\begin{array} T(n) & =2T(n-1), &\text{if } n>0 \\ & =1, & \text{otherwise} \end{array}$

  1. $O(n \log n)$
  2. $O(n^2)$
  3. $O(2^n)$
  4. $O(n)$
in Algorithms recategorized by
by
1.6k views

3 Answers

1 vote
1 vote

$T(0) = 1 = $ $2^{0} $

$T(1) = 2T(0) = 2 = $$ 2^{1} $

$T(2) = 2 T(1) = 2.2 = $ $2^{2} $

$T(3) = 2 T(2) = 2.2.2= $ $2^{3} $

$.......$

$T(n) = 2T(n-1) = 2.2.2.2.2....n times =$ $ 2^{n} $

$\therefore T(n) = O(2^{n})$

Hence Option C is the correct answer.

1 vote
1 vote
T(n) = 2T (n - 1) + 1
= 2 [2T(n - 2) + 1] + 1
= 2^2 T(n - 2) + 3

= 2^kT(n - k) + (2^k - 1)
= 2^n-1T(1) + (2^n-1 - 1)
= 2^n-1+ 2^n-1 - 1
= 2^n - 1
≅ O( 2^n )
0 votes
0 votes

by master theorem for decreasing function:

option C is correct.

refer:-> https://www.geeksforgeeks.org/master-theorem-subtract-conquer-recurrences/