CS 210 – Fundamentals of Programming I
Spring 2007 – In-class Exercise for 4/16/07 & 4/17/07


Name(s):


(10 points) Complete this exercise in pairs. Write the answers to the written part in this assignment sheet and print out the program when you are done. The purpose of this exercise is to continue working with recursive functions.


Assignment

0. Create a new project, then download file inclass25.cpp from the course webpage under today's date to your project folder. This program is an implementation of the main program that will read in the number of disks and call the function Hanoi to print out the solution to the Towers of Hanoi problem for that many disks.


1. (5 points) Add the prototype and a definition for the Hanoi function developed in lecture. Build and run this program. Make sure it is correct.


2. (5 points) When you are confident your program works correctly, answer the following questions:


a. What makes the Hanoi function a recursive function?




b. What is the base (or anchor) case of the Hanoi function?





c. What are the recursive (or inductive) steps of the Hanoi function?







When you have completed this exercise, print out your program file and turn it in with one copy of this exercise sheet with your answers to the questions.

04/13/07 1