int gcd(int n, int m) {
if (n % m == 0) return m;
n = n % m;
return gcd(m, n);
}Related Algorithms PYQs
Exponentiation is a heavily used operation in public key cryptography. Which of the following options is the tightest upper bound …
Consider the following C code segment: ```c int IsPrime(int n) { int i; for (i = 2; i <= sqrt(n); i++) if (n % i =…
What is the Asymptotic Notation of the following recursive function: ```c int DoSomething (int n) { if (n <= 2) return 1; …
Consider the following C-program fragment in which i, j, and n are integer variables. for (i = n, j = 0; i > 0; i /= 2, j += i); L…
Consider the following recurrence: T(n) = 2T(⌊sqrt(n)⌋) + 1, T(1) = 1 Which one of the following is true?
Let w be the minimum weight among all edge weights in an undirected connected graph. Let e be a specific edge of weight w. Which o…
Free account benefits
Turn practice into measurable progress
Public PYQs and reference pages stay free. Sign in when you want GATEverse to remember what you studied and guide what to practise next.