Class BinaryTreeNode

java.lang.Object
  |
  +--BinaryTreeNode

public class BinaryTreeNode
extends java.lang.Object

Class BinaryTreeNode defines the structure of a node in a binary tree. A node consists of an Object value field, a left subtree pointer and a right subtree pointer.

This class is used in both the plain BinaryTree class, as well as in the binary search tree class BinarySearchTree class.

AN IMPORTANT NOTE ABOUT DATA ABSTRACTION: Because the data fields of this BinaryTreeNode class are declared protected, they are visible to any other class in the same package as this class. And since we are not using packages, this means that the data fields of this class are visible to any other class that is not declared in a package. This weak form of information hiding is not normally a good idea in an abstract data type, but we use it here to simplify the presentation of the binary tree methods. I.e., the methods can access the node data fields directly, without having to declare access methods in the node class.


Field Summary
protected  BinaryTreeNode left
          Pointer to the left subtree of this node
protected  BinaryTreeNode right
          Pointer to the right subtree of this node
protected  java.lang.Object value
          The data value of this node
 
Constructor Summary
BinaryTreeNode(java.lang.Object value, BinaryTreeNode left, BinaryTreeNode right)
          Construct a node with the given value and subtree pointers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

value

protected java.lang.Object value
The data value of this node

left

protected BinaryTreeNode left
Pointer to the left subtree of this node

right

protected BinaryTreeNode right
Pointer to the right subtree of this node
Constructor Detail

BinaryTreeNode

public BinaryTreeNode(java.lang.Object value,
                      BinaryTreeNode left,
                      BinaryTreeNode right)
Construct a node with the given value and subtree pointers.