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 4.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<>(rootEntry));
 23:    } // end constructor
 24:    
 25:    public void setTree(T rootData) // Disable setTree (see Segment 25.6)
 26:    {
 27:       throw new UnsupportedOperationException();
 28:    } // end setTree
 29:    
 30:    public void setTree(T rootData, BinaryTreeInterface<T> leftTree,
 31:                        BinaryTreeInterface<T> rightTree)
 32:    {
 33:       throw new UnsupportedOperationException();
 34:    } // end setTree
 35: 
 36: /* < Implementations of contains, getEntry, add, and remove are here. Their
 37:      definitions appear in subsequent sections of this chapter. Other methods
 38:      in SearchTreeInterface are inherited from BinaryTree. >
 39:     . . . */  
 40: } // end BinarySearchTree