What is the time complexity of the following recursive function: int…

GATE · 2007 · CS

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);
}

  1. A.

    Θ(n²)

  2. B.

    Θ(nlogn)

  3. C.

    Θ(logn)

  4. D.

    Θ(loglogn)

Attempted by 149 students.

Sign up free to check your answer

Sign up free

Explore the full course: Gate Guidance By Sanchit Sir

Loading lesson…