Skip to content
Related Articles

Related Articles

GATE | GATE-CS-2002 | Question 36

Improve Article
Save Article
  • Last Updated : 28 Jun, 2021
Improve Article
Save Article

The running time of the following algorithm Procedure A(n)

  If n < = 2 return (1) 
  else return (A(Image not present√nImage not present));

is best described by :
(A) O(n)
(B) O(log n)
(C) O(log Log n)
(D) O(l1)


Answer: (C)

Explanation:  

Now let the function is called k times

parul_7

Taking log on both side (base 2).

parul_8

Taking log again.

parul_9

Running time complexity = number of function calls = k = Therefore Running time complexity = parul_9.

See question 5 of https://www.geeksforgeeks.org/data-structures-and-algorithms-set-11/

 

This solution is contributed by Parul Sharma.

 

Quiz of this Question

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!