The GATE Grind

GATE 2007 CS – Question 44

Algorithms · Asymptotic Analysis and Time/Space Complexity · 2 marks · Multiple choice

Let n≥m. How many recursive calls does this C function make?

int gcd(n,m) {
 if(n%m==0) return m;
 n=n%m;
 return gcd(m,n);
}
  1. $\Theta(\log_2n)$
  2. $\Omega(n)$
  3. $\Theta(\log_2\log_2n)$
  4. $\Theta(\sqrt n)$

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: (A) $\Theta(\log_2n)$

Explanation

We are sorry we couldn't write detailed soluition for this, we are working on it!, please consider asking your own AI, its just 2-3 clicks with very minimum effort

More Asymptotic Analysis and Time/Space Complexity questions

All Asymptotic Analysis and Time/Space Complexity questions →