(Solved) : Consider Following Recursive Algorithm Input Two Integers Z Y Outputs Integer F X Y Prog Z Q29649012 . . .

Consider the following recursive algorithm that on input two integers z, y outputs some other integer f(x, y) prog(z,y) if (y <0) then prog(-x,-y) else if (y-0) then 0 else if even(v) then prog(2- x,y/2) else (x +prog(x.y – 1)) Notice, the program computes y/2 only when y is even, so the division is always exact. (a) Compute prog(x, y) on a few test values of your choice, and determine the function f(x, y) computed by the program. Your answer should include at least 5 tests (e.g., prog(4,0) 0), but you do not need to include the intermediate steps of the computation. (You may run the program on a computer if you like.) The function f(x, y) should be specified as a simple arithmetic expression in the variables x and y. (b) For this part, assume y 2 0. Prove, by induction on y, that prog(x, y) correctly computes f(x, y). Your answer should start with a formal statement of the property you intend to prove (with properly quantified variables), followed by a clear and well written proof of the statement (c) Prove that prog(x, y) correctly computes f(x, y) for any integer inputs x,y. (You may use the result of part (b) if you like.) Show transcribed image text
Expert Answer
Answer to Consider Following Recursive Algorithm Input Two Integers Z Y Outputs Integer F X Y Prog Z Q29649012 . . .
OR