Question: 6 Recursive Algorithm and Induction 1 . Give a recursive algorithm that takes as input two non - negative integers x and y and returns
Recursive Algorithm and Induction
Give a recursive algorithm that takes as input two nonnegative integers x and y and
returns their sum, x y However, the only arithmetic operation your algorithm is
allowed to perform is incrementing an integer value, eg x and decrementing an
integer value, eg x
Use induction to prove that your algorithm always returns a correct answer.
State a correct claim about the number of increment and decrement operations your
algorithm makes to compute x y and use induction to prove that your claim is correct.
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
