0
Write pseudocode for computing GCD (m,n) where m=525 and n=125 and calculate worst time complexity of the problem.
Algorithm
5 odpowiedzi
+ 3
by the way:
mod --> modulus operator (in many languages %)
the mod operator calculates the remainder of a division
+ 2
I know the euclidian algorithm to calculate the gcd:
525 mod 125 = 25
125 mod 25 = 0
--> gdc (525,125) = 25
remainder = m mod n
while (remainder != 0)
m = n
n = remainder
remainder = m mod n
end while
print n //remainder is 0 --> n is your gcd
But I don't know how to caculate the time complexity.
+ 1
Thanks.
0
I know the GCD. But don't know how to calculate the worst time complexity of this problem.
I have doubt about the last question