All functions should be written in pseudocode. See the pseudocode manual for the recommended syntax and other tips. Please try to stick to this format, and print or type your answers neatly.
(5 pts) Write an iterative function
(5 pts) Write a recursive function
Both of these had better have one or more return statements to return the required counts.
(10 pts) Write an iterative (nonrecursive) function
CopyCell(P) creates and returns a pointer to a new cell, identical to the one pointed to by P.
CopyPoly(P) creates and returns a pointer to a whole new polynomial identical to the one pointed to by P. This will be helpful when exactly one of the polynomials has no more terms.
(10 pts) Consider the following function, which computes the minimum value in an array of n integers:
MinValue(A : integer array, n : integer) : integer { x : integer if n = 1 then return A[0] else { x := MinValue(A, n - 1) if x < A[n - 1] then return x else return A[n - 1] } }
Use induction to prove that this function is correct when called with n > 0. That is, prove that it really does return the minimum value in the array A. Your proof should include the basis step and the inductive step.