edited by
44,345 views
77 77 votes

Consider the following recurrence:

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

Which one of the following is true?

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

10 Answers

Best answer
75 75 votes

$T(n) = 2T\left(n^{\frac{1}{2}}\right)+1$

           $ = 2\left(2T\left(n^{\frac{1}{2^2}}\right) + 1\right) + 1 $

           $ = 4\times T\left(n^{\frac{1}{2^2}}\right) + 5 $

           $ = 8\times T\left(n^{\frac{1}{2^3}}\right) + 13 \\ \cdots$

           $=2^{(\lg \lg n)} + 2 \times \lg \lg n  + 1\text{ (Proved below)} $

           $= \Theta(\lg n)$


$n^{\frac{1}{2^k}} = 2 \\ \text{(Putting 2 so that we can take log.}\\\text{One more step of recurrence can't change the complexity.)} \\\implies \frac{1}{{2^k}} \lg n = 1 \text{(Taking log both sides)}\\\implies \lg n = 2^k \\\implies k = \lg \lg n$

So, answer is B, $T(n) = \Theta(\log n)$

edited by
1 flag
68 68 votes
$T(n)=2T({\sqrt{n}})+1$

Put, $n=2^m$

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

$T(log2^m)=2T(log2^{m/2})+c$

$T(m)=2T(m/2)+c$

Using case 1 of master theorem,

$=\Theta(m)$

SInce, $n=2^m$

$= \Theta(\log n)$
edited by
25 25 votes
$T(n)=2T(\sqrt{n})+1$

          $ =2T(2m)+1$    $n=2^{m}$ , $m=log n$

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

           $ =O(m)$

           $=O(log n)$
edited by
14 14 votes

$Ans:B$


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

Assume $n=2^k$

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

Assume $T(2^k)=S(k)$

$S(k)=2S(k/2)+1$

Apply Master Theorem

$S(k)=\Theta(k)$

Now just do the reverse

$T(2^k)=\Theta(k)$

Now replace with $k=log_{2}n$

$T(2^{log_{2}n})=\Theta(log_{2}n)$

$T(n)=\Theta(log_{2}n)$

 

7 7 votes

asume n=2k and k=log n

T(2k)=T(2k/2)+1

asume T(2)=S(k)

now S(k)=s(k/2)+1

use master theorm a=1 andb=2

T(2k)=logk

T(n)=log log(n)

5 5 votes

Unrolling the recursion,

T(n)  =  2T(n^(1/2)) + 1
=  2^2T(n^(1/4)) + 2
= 2^3T(n^(1/8)) + 3
.
.    k  steps
.
=  2^kT(n^(1/2k)) + k              …………. (1)

Using the Base case,

n^(1/2k) = 2
Taking log on both sides
log2n = 2k
k = log2log2n

From (1),

T(n) =  log2n  +  log2log2n
= Theta(log2n)

Here log2n : log(base 2) n

1 flag:
✌ Low quality (Navjeet singh saheb)
Answer:
Position:
Show:

Related questions

66 66 votes
6 answers 6 answers
36.8k
36.8k views
Rucha Shelke asked Sep 26, 2014
36,807 views
A CPU generates $32$-bit virtual addresses. The page size is $4$ KB. The processor has a translation look-aside buffer (TLB) which can hold a total of $128$ page table en...
83 83 votes
7 answers 7 answers
40.3k
40.3k views
Rucha Shelke asked Sep 18, 2014
40,307 views
Consider the following statements about the context free grammar$$G = \left \{ S \rightarrow SS, S \rightarrow ab, S \rightarrow ba, S \rightarrow \epsilon \right \} $$$G...
88 88 votes
16 answers 16 answers
56.4k
56.4k views
Arjun asked Jul 6, 2016
56,400 views
Consider the following segment of C-code:int j, n; j = 1; while (j <= n) j = j * 2;The number of comparisons made in the execution of the loop for any $n 0$ is:$\lceil \...
78 78 votes
10 answers 10 answers
46.9k
46.9k views
Kathleen asked Oct 9, 2014
46,860 views
The average number of key comparisons required for a successful search for sequential search on $n$ items is$\dfrac{n}{2}$$\dfrac{n-1}{2}$$\dfrac{n+1}{2}$None of the abov...