Project #3
Due Date: beginning of class, Monday, Feb. 24, 2003
This project can be stated very simply: develop a new version of the
KnightSequence
class that uses a linked list instead of an array to implement the sequence,
and run the KnightTour you developed for Project 2, with the new
class instead of the old one. Here are some more comments:
-
The new class must present exactly the same interface to the client
program: exactly the same methods, same parameters, etc. You must be able
to run the Project 2 KnightTour without changing it at all.
-
The class is reimplemented by defining new data structures and reimplementing
all of the methods to work with them. Use the MagazineList class
as a model for your new class.
-
Start by saving a copy of your existing KnightSequence class. (For example,
just type cp KnightSequence.java KnightSequence-save.java.)
Then modify the original class file by deleting the data structures, and
the bodies of all the methods, and filling in new data structures and bodies.
-
The new implementation must use a linked list with front and rear references,
as suggested on p. 646 of Lewis/Loftus. Using front and rear references,
the add method is O(1) instead of O(N) with only front references. You'll
need two private inner classes: one to represent list nodes, to represent
list headers.
What to submit:
Follow the guide distributed in lab.