Question: ( 5 . 4 . 1 5 ) The greatest common divisor of positive integers a and b can be defined recursively as follows: Basis
The greatest common divisor of positive integers a and b can be defined recursively as follows: Basis Step: If a b then gcdab a Recursive Step: If a b then gcdab gcdab a and if a b then gcdab gcda b b Suppose that you are given two positive integers, a and ba Give pseudocode for a recursive algorithm that computes the greatest common divisor of a and b For example, given a and b your algorithm should return gcd gcd gcd Given a and b it should return gcd gcd gcd gcd gcd gcdb State a lemma establishing the correctness of your algorithm. c Prove that your algorithm is correct. Hint: When recursing, neither a nor b is guaranteed to get smaller. Rather, consider inducting over a b a single integer that encapsulates the entire size of the problem.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
