Lab 5 - Saruman and Sauron Play with Iterators
Due: Monday, October 18, 2004 at 9:00 AM
Do the laboratory at the end of Chapter 7. There are no practice questions or design for this week because of reading period.
When you implement your SubsetIterator that extends AbstractIterator, be sure to import structure.* and java.util.Iterator at the top of your file. Also remember that your SubsetIterator should be completely generic. It should know nothing about the values of the Objects in the Vector.
For testing, write a main method of your SubsetIterator that creates a Vector with the Integers from 0 through 7, creates a SubsetIterator with this Vector, and then prints out all subsets returned and a count of the subsets returned. Make sure you end up with 256 subsets printed.
Write the main method to solve the two-towers problem in a separate class called TwoTowers, proceeding as specified at the top of p. 165.
When you're finished, create and submit a tar file lab5.tar that includes the following:
Also in the README file, answer these extra questions (let's call them thought question 3): How long does it take your program to find the answer to the 20-block problem? (hint: try the "time" command rather than instrumenting your source code with a timer). Based on the time taken to solve the 20-block problem, about how long do you expect it would take to solve the 21-block problem? What is the actual time? How about the 25-block problem? Do these agree with your expectations, given the time complexity of the problem? What about the 40- and 60-block problems? (You can try these if you're very patient, but for the purposes of this question, just estimate based on the run times of the smaller problems).