...
Computer-Networks
October 25, 2023
Research Aptitude
October 25, 2023
Computer-Networks
October 25, 2023
Research Aptitude
October 25, 2023

GATE 2007

Question 44

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
θ (log2 n)
B
Ω (n)
C
θ (log2log2 n)
D
θ(√n)
Question 44 Explanation: 
The given code is to calculate the greatest common divisor (GCD) using Euclidean algorithm.
Then, time complexity is = O(log(a∙b) = O(log(a+b)) = O(log n)
Correct Answer: A
Question 44 Explanation: 
The given code is to calculate the greatest common divisor (GCD) using Euclidean algorithm.
Then, time complexity is = O(log(a∙b) = O(log(a+b)) = O(log n)
0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
error: Alert: Content selection is disabled!!