CS 102: Data Structures

Spring 2006


Lab 4

Recursion

Solving a Maze


Introduction

In this lab you will work with a program to solve a maze. Several files contains information about the structure of the maze program, but you should focus on the discussion given in the web page version found in the subfile mazepart4html.zip in the file lab4.zip. The main page to open is mazepart4.htm. Then read over the discussion of recursive solutions given in the document mazecasestdyPart56.rtf, part 5. Your lab assignment will be some of the exercises from this part.

Specifications

The starting code for your program is in the zip file mazepart5Code.ZIP. For the first part of the lab the class RecursiveWalker0 has already been defined. However, you need to add a data structure and code so that there is no infinite recursion. The second part of the lab is to factor out the elements that would be common to any recursive solution into an abstract class, then reimplement RecursiveWalker0 as a subclass. The last part is to use this inheritance hierarchy to write another version of the RecursiveWalker that uses absolute directions (North, South, East, West) instead of relative directions (forward, right, left, reverse).


To Do

Read the background materials given as a web page in the mazepart4html directory from the file lab4.zip. Start reading by opening the MazeCaseStudyPart4.htm page from the subfile mazepart4html.zip. The corresponding code is in the subfile mazepart4Code.zip. Then read MazeCaseStudypart5.doc, also in the lab5.zip file. Your task will be to complete exercises 45, 47, and 48. The initial code to use, as described in part 5, is in the file mazepart5Code.zip. Files for testing your program are in the file MazeFiles.zip.