Homework 1

Draw a picture that describes the execution of the recursive function below, given x=1 and y=8 at function invocation. Be sure to include the values of x and y for each call to the function, the value returned from each function call, and the order of the function calls. You may use any notation that you wish as long as your meaning is clear.

int nonsense(int x, int y) { if (x > y) return 0; if (x == y) return 1; if ((x % 2) == 0) return(nonsense(x, y-1) + nonsense(x+1, y)); else return(nonsense(x+1, y-1)); }

Last Modified: Monday, September 11, 2000