Open In App

GATE | GATE-CS-2007 | Question 45

Like Article
Like
Save
Share
Report
What is the time complexity of the following recursive function:
int DoSomething (int n) 
{
  if (n <= 2)
    return 1;
  else  
    return (DoSomething (floor(sqrt(n))) + n);
}

                    
(A) \theta(n) (B) \theta(nlogn) (C) \theta(logn) (D) \theta(loglogn) (A) A (B) B (C) C (D) D

Answer: (D)

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

Quiz of this Question

Last Updated : 28 Jun, 2021
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads