GATE CSE
First time here? Checkout the FAQ!
x
0 votes
103 views

Can you please find time complexity of the recurrence using Variable Substitue method and Master Theroem:

What is the time complexity of the following recursive function 
int recursion (int n) 

if(n ≤ 1) 
return 1; 
else 
return(recursion(sqrt(n)) + 1); 
}

 

// i solved it using substitution method.

asked in Algorithms by Veteran (14.6k points)  
edited by | 103 views

1 Answer

+2 votes
Best answer


T(n) = T(root(n))+1
let n= 2k
T(2^k)=T(2(k/2))+1
let T(2K) = G(k)
G(k) = G(k/2)+1
using extended master's theorem
a=1 b=2 k=0,p=0
a=bk it will be G(k) = O(logk) = T(2k)
we know K=logn substitute in O(logk) = O(loglogn)

Credits: Sanju

answered by Veteran (14.6k points)  
edited by

Related questions

0 votes
1 answer
2
+1 vote
1 answer
3
asked in Algorithms by harshit agarwal (379 points)   | 65 views


Top Users Mar 2017
  1. rude

    5246 Points

  2. sh!va

    3054 Points

  3. Rahul Jain25

    2920 Points

  4. Kapil

    2732 Points

  5. Debashish Deka

    2602 Points

  6. 2018

    1574 Points

  7. Vignesh Sekar

    1440 Points

  8. Bikram

    1432 Points

  9. Akriti sood

    1420 Points

  10. Sanjay Sharma

    1128 Points

Monthly Topper: Rs. 500 gift card

21,553 questions
26,902 answers
61,258 comments
23,269 users