GATE | GATE-CS-2006 | Question 51

Consider the following recurrence:

gate_2006_51

Which one of the following is true?



(A) T(n) =

\theta

(loglogn)
(B) T(n) =

\theta

(logn)
(C) T(n) =

\theta

(sqrt(n))
(D) T(n) =

\theta

(n)
(A) A
(B) B
(C) C
(D) D


Answer: (B)

Explanation:  

Background Required – Recurrence Solving using Substitution Method.


Answer – B
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

Related :
http://geeksquiz.com/algorithms-analysis-of-algorithms-question-17-2/

 

This solution is contributed by Pranjul Ahuja .

 

 

Quiz of this Question



My Personal Notes arrow_drop_up


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.