asd_library.tree.bstree
Class BSTNode

java.lang.Object
  |
  +--asd_library.tree.bstree.BSTNode

public class BSTNode
extends java.lang.Object

Basic node stored in a binary search tree.


Field Summary
protected  java.lang.Comparable key
          The key of the node.
protected  BSTNode leftChild
          The left child node of current node.
protected  BSTNode rightChild
          The right child node of current node.
 
Constructor Summary
  BSTNode()
          Constructs a new node.
  BSTNode(java.lang.Comparable el)
          Constructs a new node.
protected BSTNode(java.lang.Comparable el, BSTNode par, BSTNode lt, BSTNode rt)
           
 
Method Summary
 java.lang.Comparable getKey()
          Returns the key of the node.
 BSTNode getLeftChild()
          Returns the left child of the node.
 BSTNode getRightChild()
          Returns the right child of the node.
 boolean isLeaf()
          Verifies if this BSTNode is a leaf.
 void visit()
          Prints the String that represents the key of the node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

key

protected java.lang.Comparable key
The key of the node.


leftChild

protected BSTNode leftChild
The left child node of current node.


rightChild

protected BSTNode rightChild
The right child node of current node.

Constructor Detail

BSTNode

public BSTNode()
Constructs a new node.


BSTNode

public BSTNode(java.lang.Comparable el)
Constructs a new node.

Parameters:
el - the element to insert.

BSTNode

protected BSTNode(java.lang.Comparable el,
                  BSTNode par,
                  BSTNode lt,
                  BSTNode rt)
Parameters:
el -
lt -
rt -
Method Detail

getKey

public java.lang.Comparable getKey()
Returns the key of the node.

Returns:
the key of this node

getLeftChild

public BSTNode getLeftChild()
Returns the left child of the node.

Returns:
the left child BSTNode.

getRightChild

public BSTNode getRightChild()
Returns the right child of the node.

Returns:
the right child BSTNode.

visit

public void visit()
Prints the String that represents the key of the node.


isLeaf

public boolean isLeaf()
Verifies if this BSTNode is a leaf.

Returns:
true if this node is a leaf, false otherwise.