Question: IV. Finding greatest common divisor, for example the largest number that divides both 20 and 30 is 10. So gcd (20,30)=10, gcd (1,15)-1, gcd

IV. Finding greatest common divisor, for example the largest number that divides both 20 and 30 is 10. So gcd (20,30)=10, gcd (1,15)-1, gcd (25,25)-25. The gcd can be found using the strategy below. Since a and b can be very large numbers, assume both start as n/2-bit numbers with divide taking lg. (n/2) steps and subtraction taking n/2 steps i. Give the pseudocode for gcd. ii. Find T(n) where n is the number of bits of a + number of bits of b (both are n/2 bit numbers initially which add to n bits). iii. Using the worst case situation, solve T(n) to find closed form running time Given gcd(1,b)=gcd(a,1)=1 for any a.b>=1 2 ged(a/2, b/2) if a, b are even gcd(a, b) = gcd (a, b/2) if a is odd, b is even gcd ((a b)/2, b) if a, bare odd
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
