Class BinaryTreePlusNode

java.lang.Object
  |
  +--BinaryTreePlusNode

public class BinaryTreePlusNode
extends java.lang.Object

Class BinaryTreePlusNode is an extension of the plain BinaryTreeNode class. BinaryTreePlusNode adds a height field and some other potentially useful fields for use in AVL trees.


Field Summary
protected  int height
          Height of subtree rooted at this node
protected  BinaryTreePlusNode left
          Pointer to the left subtree of this node
protected  BinaryTreePlusNode parent
          Parent node
protected  int position
          Ordinal position of the value this node
protected  BinaryTreePlusNode right
          Pointer to the right subtree of this node
protected  int size
          Size of subtree rooted at this node
protected  java.lang.Object value
          The data value of this node
 
Constructor Summary
BinaryTreePlusNode(java.lang.Object value, BinaryTreePlusNode left, BinaryTreePlusNode right)
          Construct a node with the given value and subtree pointers.
 
Method Summary
 boolean isLeaf()
          Return tree if this is a leaf node, i.e., both right and left pointers are null.
protected  boolean onlyLeftChild()
          Return true if this node is an only left child.
protected  boolean onlyRightChild()
          Return true if this node is an only left child.
 java.lang.String toString()
          Convert this to a preorder string of the same form as BinarySearchTree.toString.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

value

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

left

protected BinaryTreePlusNode left
Pointer to the left subtree of this node

right

protected BinaryTreePlusNode right
Pointer to the right subtree of this node

height

protected int height
Height of subtree rooted at this node

size

protected int size
Size of subtree rooted at this node

position

protected int position
Ordinal position of the value this node

parent

protected BinaryTreePlusNode parent
Parent node
Constructor Detail

BinaryTreePlusNode

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

isLeaf

public boolean isLeaf()
Return tree if this is a leaf node, i.e., both right and left pointers are null.

toString

public java.lang.String toString()
Convert this to a preorder string of the same form as BinarySearchTree.toString.
Overrides:
toString in class java.lang.Object

onlyLeftChild

protected boolean onlyLeftChild()
Return true if this node is an only left child.

onlyRightChild

protected boolean onlyRightChild()
Return true if this node is an only left child.