edited by
27,775 views
58 58 votes

Consider the recurrence function

$$T(n) = \begin{cases} 2T(\sqrt{n})+1, & n>2 \\ 2, & 0 < n \leq 2 \end{cases}$$

Then $T(n)$ in terms of $\Theta$ notation is

  1. $\Theta(\log \log n)$
  2. $\Theta( \log n)$
  3. $\Theta (\sqrt{n})$
  4. $\Theta(n)$

6 Answers

Best answer
100 100 votes

$T(n)=2T({\sqrt{n}})+1$

Put, $n=2^m$ which implies $\sqrt n = n^{1/2} =2^{m/2}$

$\implies T(2^m)=2T(2^{m/2})+1$

put, $T(2^m) =S(m)$ which implies $T(2^{m/2}) = S(m/2)$

$\implies S(m)=2S(m/2)+1$

Using case 1 of master method ,

$=\Theta(m) = \Theta(\log n)$

 https://gateoverflow.in/1829/gate2006-51-isro2016-34?show=37791#c37791

Correct Answer: $B$

edited by
49 49 votes

Though $\sqrt{n}=2^m$ is the shortest method.

$T(n)=2T(n^{1/2}) +1$

$=2 *[ 2 T((n^{1/2})^{1/2}) +1] +1$

$=2^{2} T((n^{1/4}) +2 +1$

$=2^{3} T((n^{1/2^{3}}) +4 +2 +1$

$=2^{k} T((n^{1/2^{k}}) +2^{k-1}+ 2^{k-2}+..............+4 +2 +1$

$=2^{k} T((n^{1/2^{k}}) +[(2^{k}-1)/ 2-1] * 2^{0}$


as per given termination condition is $n^{1/2^{k}} =2$

$\Rightarrow log(n^{1/2^{k}}) =log(2)$

$\Rightarrow log(n) =2^{k}$

$\Rightarrow log( log(n)) =k$


inserting value of k or 2^k in above equation

$T(n)= log(n) * T(2) + log(n) - 1$

$T(n)= 3 log(n) - 1$


$T(n)= \Theta (log(n))$

Answer is B

2 2 votes
Option B

put n=2^m

T(2^m)=2T(2^m/2) + 1

put (2^m)=S(m)

S(m)=2S(m/2)+1

=Theta(m)=Theta(logn)-------Masters Thm
Answer:
Position:
Show:

Related questions

68 68 votes
4 answers 4 answers
35.8k
35.8k views
Arjun asked Feb 14, 2017
35,844 views
A message is made up entirely of characters from the set $X=\{P, Q, R, S, T\}$. The table of probabilities for each of the characters is shown below:$$\begin{array}{|c|c|...
71 71 votes
10 answers 10 answers
41.2k
41.2k views
Madhav asked Feb 14, 2017
41,154 views
Consider the following C functionint fun(int n) { int i, j; for(i=1; i<=n; i++) { for (j=1; j<n; j+=i) { printf("%d %d", i, j); } } }Time complexity of $fun$ in terms of ...
40 40 votes
5 answers 5 answers
13.1k
13.1k views
Madhav asked Feb 14, 2017
13,109 views
The Breadth First Search (BFS) algorithm has been implemented using the queue data structure. Which one of the following is a possible order of visiting the nodes in the ...
36 36 votes
8 answers 8 answers
12.0k
12.0k views
khushtak asked Feb 14, 2017
11,987 views
Match the algorithms with their time complexities:$$\begin{array}{|l|l|}\hline \textbf{Algorithms} & \textbf{Time Complexity} \\\hline \text{P. Tower of Hanoi with $n$...