recategorized by
3,023 views
3 votes
3 votes

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)

  1. $O(n)$
  2. $O(2^n)$
  3. $O(1)$
  4. $O(\log n)$
recategorized by

2 Answers

Best answer
9 votes
9 votes

$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

selected by
1 votes
1 votes
just do  by substitution nd observation for saving tym

T(0)=1 given

T(1)=2 on putting

T(2)=2*2

T(3)=2*2*2

...............T(n)=2*2*2*2.............n tymes=2^n
Answer:

Related questions

1 votes
1 votes
2 answers
1
gatecse asked Dec 17, 2017
3,333 views
The characters of the string $\text{K R P C S N Y T J M}$ are inserted into a hash table of the size of size $10$ using a hash function$h(x)=(ord(x)-ord(A)+1)$ $mod$ $10$...
1 votes
1 votes
1 answer
2
gatecse asked Dec 17, 2017
1,838 views
Quick-sort is run on $2$ inputs shown below to sort in ascending order :$1,2,3\ldots n$$n,n-1,n-2\ldots 1$Let $C$1 and $C2$ be the number of comparisons made for A and B ...
3 votes
3 votes
2 answers
3
gatecse asked Dec 17, 2017
1,429 views
A sorting technique is called stable ifIf it takes $O(n\log n)$ time.It uses divide and conquer technique.Relative order of occurrence of non-distinct elements is maintai...
4 votes
4 votes
1 answer
4
gatecse asked Dec 17, 2017
1,716 views
Match the following and choose the correct answer for the order $A,B,C,D$$$\begin{array}{|ll|ll|}\hline \text{A.} & \text{Strassen matrix multiplication} & \text{p.} & ...