Open In App
Related Articles

GATE | GATE-CS-2007 | Question 44

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report
In the following C function, let n >= m.
int gcd(n,m)
{
  if (n%m ==0) return m;  
  n = n%m;
  return gcd(m,n);
}

                    
How many recursive calls are made by this function? (A) \theta(logn)? (B) \Omega(n) (C) \theta(loglogn) (D) \theta(sqrt(n)) (A) A (B) B (C) C (D) D

Answer: (A)

Explanation: See question 4 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