Algorithms | Analysis of Algorithms | Question 14

Last Updated :
Discuss
Comments

In the following C function, let n >= m. 

C
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) [Tex]\\theta  [/Tex](log(n))
(B) [Tex]\\Omega  [/Tex](n)
(C) [Tex]\\theta  [/Tex](log(log(n)))
(D) [Tex]\\theta  [/Tex](sqrt(n))

A

B

C

D

Share your thoughts in the comments