Question: Recursive Algorithm and Induction 1. Give a recursive algorithm that takes as input two non-negative integers x and y and returns their sum, x +

Recursive Algorithm and Induction

1. Give a recursive algorithm that takes as input two non-negative integers x and y and returns their sum, x + y. The only arithmetic operation your algorithm can perform is incrementing an integer value, e.g. x++, and decrementing an integer value, e.g. x.

2. Use induction to prove that your algorithm always returns a correct answer.

3. 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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!