Homework 9

22C:21 Computer Science II: Data Structures
Due Friday, April 9, 2008

1. (3 points) Exercise 9.1, page 373.

2. (3 points) Exercise 9.7, part a, page 374.

3. (4 points) Exercise 9.15, page 373.

4. (25 points) Implement a program to find solution paths in mazes.

For this problem, mazes will be restricted to rectangular grids of cells, like those discussed in Section 8.7 (Skim this section of the book. You do not need to understand nor implement the maze creation method, just the maze representation.) There are three differences between the mazes described Section 8.7 and those that you must be able to handle:
Your program must take five arguments Your program should output the lowest cost path from the startCell to the endCell.

You should represent the maze using a weighted undirected graph, as follows:
The input file format for the maze is as follows: Here are a few sample maze files: smallmaze3.text, maze7x11.text, maze1.text, maze2.text.
Note: Code to generate maze files and also to graphically display and interact with mazes: mazeio.jar, TestMazeIO.java. To use these files in Eclipse, do:
  1. create a project containing the TestMazeIO.java code (later, you can add your solving code to this project, but test this project by itself first)
  2. Select "Project", then "Properties", then "Java Build Path", then click on the "Libraries" tab, and then on the "Add External JARs..." button. Navigate until you find the place where you put the "mazeio.jar" file, click on it and then click "Open" and, finally, the "OK" button.
  3. If you now run the "TestMazeIO" project a window with small maze should appear. If it does, you are all set - next you should read the comments in MazeIO.java to see how to run various examples.


Submit your program (with sample output and, of course, the required README file) via ICON.