java.lang.Object BST
public class BST
A binary search tree for Strings.
Constructor Summary | |
---|---|
BST()
Constructs an empty binary search tree. |
Method Summary | |
---|---|
void |
clear()
Makes the tree empty. |
boolean |
contains(String item)
Searches for an item in the tree. |
int |
count()
Counts the items. |
boolean |
delete(String item)
Deletes item from the tree. |
int |
depth(String item)
Finds an item's depth in the tree. |
int |
height()
Finds the height of the tree. |
String |
inOrder()
Returns in-order tree contents. |
boolean |
insert(String item)
Inserts an item in the tree. |
boolean |
isEmpty()
Returns true if the tree is empty. |
String |
postOrder()
Returns post-order tree contents. |
String |
preOrder()
Returns pre-order tree contents. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BST()
Method Detail |
---|
public boolean isEmpty()
public void clear()
public boolean contains(String item)
item
- the item to search for.
public int depth(String item)
item
- the item to find.
public int height()
public int count()
public String inOrder()
public String preOrder()
public String postOrder()
public boolean insert(String item)
item
- the item to insert.
public boolean delete(String item)
item
- the item to delete.