edu.olemiss.cs211
Class BinarySearchTree<T extends java.lang.Comparable<T>>

java.lang.Object
  extended by edu.olemiss.cs211.BinarySearchTree<T>
Type Parameters:
T -

public class BinarySearchTree<T extends java.lang.Comparable<T>>
extends java.lang.Object

Binary Search Tree implementation


Constructor Summary
BinarySearchTree()
          Creates an empty binary search Tree
 
Method Summary
 boolean add(T element)
          Inserts an element of type T into the Binary Search Tree
 boolean find(T element)
          searches the binary search tree recursively for the element
 boolean isEmpty()
          method to check if the Tree is empty
 void printInorder()
          prints the data in the nodes encountered during the in-order traversal of the tree
 void printLevelOrder()
          prints the data in the nodes encountered during the level-order traversal of the tree
 void printPostorder()
          prints the data in the nodes encountered during the post-order traversal of the tree
 void printPreorder()
          prints the data in the nodes encountered during the pre-order traversal of the tree
 int size()
          method that
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BinarySearchTree

public BinarySearchTree()
Creates an empty binary search Tree

Method Detail

size

public int size()
method that

Returns:
the number of nodes in the tree

isEmpty

public boolean isEmpty()
method to check if the Tree is empty

Returns:
true for empty Tree

add

public boolean add(T element)
Inserts an element of type T into the Binary Search Tree

Parameters:
element - of comparable type T
Returns:
True if insertion was successful

find

public boolean find(T element)
searches the binary search tree recursively for the element

Parameters:
element -
Returns:
true if the element is present

printPreorder

public void printPreorder()
prints the data in the nodes encountered during the pre-order traversal of the tree


printInorder

public void printInorder()
prints the data in the nodes encountered during the in-order traversal of the tree


printPostorder

public void printPostorder()
prints the data in the nodes encountered during the post-order traversal of the tree


printLevelOrder

public void printLevelOrder()
prints the data in the nodes encountered during the level-order traversal of the tree