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));
}
- This homework is due by midnight, Friday September 15.
- The homework may be handwritten as long as it is orderly and legible.
If it cannot be understood by the grader, it is wrong.
- Turn in a hard copy of this homework. Do NOT submit it electronically.
- Put your name and discussion section number on your homework.
- For Ms. Mitchell's sections, you may turn your work in at Thursday's
(9/14) lecture, put it under her office door (ECS 225-L) or ask the
receptionist in ECS 210 to put it in her mailbox. Do NOT turn it in at
discussion.
- For Mr. Kukla's sections, you may turn your work in at Wednesday's (9/13) lecture, put it under his office door (ECS 216) or ask the receptionist in ECS 210 to put it in his mailbox. Do NOT turn it in at discussion.
Last Modified: Monday, September 11, 2000