Source of BinarySearchTree.java


  1: package TreePackage;
  2: import java.util.Iterator;
  3: /**
  4:    A class that implements the ADT binary search tree by extending BinaryTree.
  5:    Recursive version.
  6:  
  7:    @author Frank M. Carrano
  8:    @author Timothy M. Henry
  9:    @version 5.0
 10: */
 11: public class BinarySearchTree<T extends Comparable<? super T>>
 12:              extends BinaryTree<T> implements SearchTreeInterface<T>
 13: {
 14:    public BinarySearchTree()
 15:    {
 16:       super();
 17:    } // end default constructor
 18:    
 19:    public BinarySearchTree(T rootEntry)
 20:    {
 21:       super();
 22:       setRootNode(new BinaryNode<T>(rootEntry));
 23:    } // end constructor
 24:    
 25:    // Disable setTree (see Segment 26.6)
 26:    public void setTree(T rootData, BinaryTreeInterface<T> leftTree,
 27:                                    BinaryTreeInterface<T> rightTree)
 28:    {
 29:       throw new UnsupportedOperationException();
 30:    } // end setTree

 32: /* Implementations of contains, getEntry, add, and remove are here.
 33:    . . .
 34:    Other methods in SearchTreeInterface are inherited from BinaryTree.  */
 35: } // end BinarySearchTree