introExam.BinarySearchTree
Class BST

java.lang.Object
  extended byintroExam.BinarySearchTree.BST
Direct Known Subclasses:
ExtendedBST

public class BST
extends java.lang.Object

A minimal BST class using a nested BSTNode class, for the 15-111/200 Final Exam/Fall 2004

Students are not permitted to modify or augment this class in any way. This file must not change.

Note that all instance variables declared in the nested BSTNode class are public and that value is also declared with the final access modifier.

Thus, the information that they store can be accessed through these names directly, or through the provided getters/setters (except value cannot be changed once it has been initialized, and it has no setter).


Nested Class Summary
protected  class BST.BSTNode
           
 
Field Summary
protected  BST.BSTNode root
           
 
Constructor Summary
BST()
          The default constructor: creates an empty binary search tree
 
Method Summary
private  BST.BSTNode insert(BST.BSTNode root, java.lang.Comparable value)
          This is a helper method -- no further description available
 void insert(java.lang.Comparable data)
          Inserts a value into the proper position of a binary search tree.
private  java.lang.String niceTreeString(BST.BSTNode t, java.lang.String indent)
          This is a helper method -- no further description available
 java.lang.String toString()
          Provides a nice string represention of a BST.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

root

protected BST.BSTNode root
Constructor Detail

BST

public BST()
The default constructor: creates an empty binary search tree

Method Detail

insert

public void insert(java.lang.Comparable data)
Inserts a value into the proper position of a binary search tree.


insert

private BST.BSTNode insert(BST.BSTNode root,
                           java.lang.Comparable value)
This is a helper method -- no further description available


niceTreeString

private java.lang.String niceTreeString(BST.BSTNode t,
                                        java.lang.String indent)
This is a helper method -- no further description available


toString

public java.lang.String toString()
Provides a nice string represention of a BST.

Students should not concern themselves with how it works -- an understanding of this is not important to this exam.