Java Reference
In-Depth Information
25.10
( Preorder iterator ) Add the following method in the BST class that returns an
iterator for traversing the elements in a BST in preorder.
/** Returns an iterator for traversing the elements in preorder */
java.util.Iterator<E> preorderIterator()
25.11
( Display tree ) Write a new view class that displays the tree horizontally with
the root on the left as shown in Figure 25.23.
F IGURE 25.23
A binary tree is displayed horizontally.
**25.12
( Test BST ) Design and write a complete test program to test if the BST class in
Listing 25.5 meets all requirements.
**25.13
( Add new buttons in BSTAnimation ) Modify Listing 25.9, BSTAnimation.java,
to add three new buttons— Show Inorder, Show Preorder, and Show Postorder—
to display the result in a label, as shown in Figure  25.24. You need also to
modify BST.java to implement the inorderList() , preorderList() , and
postorderList() methods so that each of these methods returns a List of
the node elements in inorder, preorder, and postorder, as follows:
public java.util.List<E> inorderList();
public java.util.List<E> preorderList();
public java.util.List<E> postorderList();
F IGURE 25.24
When you click the Show Inorder, Show Preorder, or Show Postorder button,
the elements are displayed in an inorder, preorder, or postorder in a label.
 
Search WWH ::




Custom Search