Next: GCD: using the method
Up: Unit 06
Previous: GCD: by directly exploiting
How many times do we execute the loop in the previous algorithm?
- best case: 1 time, when x divides y or vice-versa
E.g., gcd(500, 1000)
- worst case:
min(x, y) times, when
gcd(x, y) = 1
Ex . gcd(500, 1001)
Hence, the previous algorithm behaves bad when x and y are big and
gcd(x, y) is small.
Next: GCD: using the method
Up: Unit 06
Previous: GCD: by directly exploiting