CpSc 102, Section 1
Assignment 6 -- Extra Credit
June 18, 2000
Due: Monday, June 25 by 7:00 a.m.
Assignment: Postorder Iterator to be appended to Assignment #5.
Careful: Once you get Assignment 5 working, save it in a secure
file while you develop the postorder iterator.
The use of an external iterator is described in the text on pages 266 - 273.
You will need to
import java.util.Iterator;
and implement a class
public class PostOrderIterator implements Iterator
which contains the methods
public boolean hasNext()
// determine whether there are any more elements in this iterator
// returns true if there are more elements in this PostOrderIterator
// Otherwise, returns false
public Object next ( )
// Retrieve the next element of this PostOrderIterator
// pre: hasNext ( )
// post: return the value of the next element of this PostOrderIterator.
// Note that each element is returned only once and the the
// PostOrderIterator automatically advances to the next element.
public void remove ( )
// set up as on page 271
You will also need to add a method
public PostOrderIterator iterator ( )
// Method of the BSTStringBag class to return a PostOrderIterator that
// contains all the elements that are currently in the Bag
{
return new PostOrderIterator( root );
}
to BSTStringBag.java.
Total point value of assignment: 40 points
Not accepted late. You will need to submit BOTH BSTStringBag.java and
PostOrderIterator.java simultaneously to Assignment #6 using the handin
routine. You will find this Interface in the Java 1.3 API.
This assignment is to be done INDIVIDUALLY.
Create a file, BSTStringBag .java, which will contain a main method (used for
testing your method). In ordering the Strings, use the result returned by
the String method's compareTo method. (The result is not going to be
dictionary order because lowercase letters after uppercase letters,
so "Alice" < "Mary" < "all".)
Your main method should (as usual) contain a test program, containing several test situations. BSTStringBag.java may contain any additional methods that would be helpful. For example, you might write a method to print out "CPSC 102", your name, the assignment number, and a brief description of the assignment.
Other requirements:
The first operation of your main program must be to print "CPSC 102", your name, the assignment number, and a brief description of the assignment.
Follow the style standards to be found on your instructor's
web page for CPSC 102.
Submit your program using the handin command. There is a link to
the handin description on the CPSC 210 lab page (www.cs.clemson.edu/~lab210).
Grading rubric:
20 pts. works with your test data
20 pts. works with our test data