GATE CSE
First time here? Checkout the FAQ!
x
0 votes
84 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 (11.7k points)  
edited ago by | 84 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 (11.7k points)  
edited by

Related questions

0 votes
0 answers
2
+1 vote
1 answer
3
asked in Algorithms by harshit agarwal (337 points)   | 46 views
Top Users Jan 2017
  1. Debashish Deka

    8978 Points

  2. sudsho

    5326 Points

  3. Habibkhan

    4798 Points

  4. Bikram

    4676 Points

  5. Vijay Thakur

    4496 Points

  6. saurabh rai

    4222 Points

  7. Arjun

    4216 Points

  8. Sushant Gokhale

    3834 Points

  9. santhoshdevulapally

    3808 Points

  10. Kapil

    3736 Points

Monthly Topper: Rs. 500 gift card

19,229 questions
24,123 answers
53,257 comments
20,323 users