introExam.BinarySearchTree
Class BST.BSTNode

java.lang.Object
  extended byintroExam.BinarySearchTree.BST.BSTNode
Enclosing class:
BST

protected class BST.BSTNode
extends java.lang.Object


Field Summary
 BST.BSTNode left
           
 BST.BSTNode right
           
 java.lang.Comparable value
          Note final access modifier: cannot be changed! Also, there is no setter for value.
 
Constructor Summary
BST.BSTNode(java.lang.Comparable value)
          Constructor builds the BSTNode with the supplied parameter; it has empty subtrees.
BST.BSTNode(java.lang.Comparable value, BST.BSTNode left, BST.BSTNode right)
          Constructor builds the BSTNode with the supplied parameters.
 
Method Summary
 BST.BSTNode getLeft()
          Returns reference to the left child, or null, if none.
 BST.BSTNode getRight()
          Returns reference to the right child, or null, if none.
 java.lang.Comparable getValue()
          Returns reference to the value of the object.
 void setLeft(BST.BSTNode newLeftChild)
          Sets the left-child reference of this object to the parameter object.
 void setRight(BST.BSTNode newRightChild)
          Sets the right-child reference of this object to the parameter object.
 java.lang.String toString()
          Returns string representation of the object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

value

public final java.lang.Comparable value
Note final access modifier: cannot be changed! Also, there is no setter for value.


left

public BST.BSTNode left

right

public BST.BSTNode right
Constructor Detail

BST.BSTNode

public BST.BSTNode(java.lang.Comparable value)
Constructor builds the BSTNode with the supplied parameter; it has empty subtrees.

Parameters:
value - to store in this node

BST.BSTNode

public BST.BSTNode(java.lang.Comparable value,
                   BST.BSTNode left,
                   BST.BSTNode right)
Constructor builds the BSTNode with the supplied parameters.

Parameters:
value - to store in this node
left - must refer to its left subtree
right - must refer to its right subtree
Method Detail

getLeft

public BST.BSTNode getLeft()
Returns reference to the left child, or null, if none.

Returns:
reference to left child

getRight

public BST.BSTNode getRight()
Returns reference to the right child, or null, if none.

Returns:
reference to right child

setLeft

public void setLeft(BST.BSTNode newLeftChild)
Sets the left-child reference of this object to the parameter object.

Parameters:
newLeftChild - which is an object of the class BSTNode

setRight

public void setRight(BST.BSTNode newRightChild)
Sets the right-child reference of this object to the parameter object.

Parameters:
newRightChild - which is an object of the class BSTNode

getValue

public java.lang.Comparable getValue()
Returns reference to the value of the object.

Returns:
reference to the value

toString

public java.lang.String toString()
Returns string representation of the object

Returns:
String reference