E - The type of element that the BinarySearchTree will hold. Please note that E must implement the
KeyElementInterface or some super class of E must implement the KeyElementInterface.K - The type of key that all elements must contain. Please note that K must implement the
Comparable interface or some super class of K must implement the Comparable interface.public interface BinarySearchTreeInterface<E extends KeyedElementInterface<K>,K extends java.lang.Comparable<? super K>>
| Modifier and Type | Method and Description |
|---|---|
void |
balance()
This method is used to balance the
BinarySearchTree. |
BinarySearchTreeInterface<E,K> |
copy()
Method to make a deep copy of the BinarySearchTree.
|
void |
delete(K key)
This is the public method used to delete a TreeItem from the
BinarySearchTree based
on the specified key. |
E |
find(K key)
Method to find and retrieve the TreeItem
with the given key if it is in the BinarySearchTree.
|
TreeNode<E,K> |
getRoot()
Method to get the current root of this BinarySearchTree
|
int |
height()
This method is used to obtain the height of the
BinarySearchTree. |
void |
insert(E element)
Method to insert the given TreeItem into the BinarySearchTree
|
boolean |
isBalanced()
This is the method the user calls to find out if the
BinarySearchTree is balanced. |
boolean |
isEmpty()
Method to find out if the BinarySearchTree is empty
|
TreeElementIterator<E,K> |
iterator()
Creates and returns a
TreeElementIterator |
void |
makeEmpty()
Method to remove all entries from the BinarySearchTree.
|
void |
setRoot(TreeNode<E,K> root)
Method to set set the root of this BinarySearchTree
|
TreeNode<E,K> getRoot()
void setRoot(TreeNode<E,K> root)
root - The new root of this BinarySearchTreeboolean isEmpty()
void makeEmpty()
BinarySearchTreeInterface<E,K> copy()
E find(K key)
key - The key that the user wishes to search forvoid insert(E element)
element - The element to insert into the BinarySearchTreevoid delete(K key) throws TreeException
BinarySearchTree based
on the specified key.key - The key of the TreeItem the user wishes to delete from the BinarySearchTree.TreeExceptionint height()
BinarySearchTree.BinarySearchTree.boolean isBalanced()
BinarySearchTree is balanced.true if the BinarySearchTree is balanced, false otherwise.void balance()
BinarySearchTree.TreeElementIterator<E,K> iterator()
TreeElementIteratorTreeElementIterator which will use this BinarySearchTree.