public class BinarySearchTree<E extends java.lang.Comparable<? super E>>
extends java.lang.Object
Constructor and Description |
---|
BinarySearchTree()
Initializes an empty binary search tree.
|
Modifier and Type | Method and Description |
---|---|
void |
add(E value)
Adds the passed value to the tree.
|
boolean |
contains(E target)
Returns true if the passed target is in the tree, false otherwise.
|
E |
largestValue()
Returns the largest element in this binary search tree, or null
if the tree is empty.
|
static void |
main(java.lang.String[] args) |
void |
remove(E value)
Removes the passed value from the tree.
|
int |
size()
Returns the number of elements in this tree.
|
E |
smallestValue()
Returns the smallest element in this binary search tree, or null
if the tree is empty.
|
java.lang.String |
toString() |
public BinarySearchTree()
public int size()
public E largestValue()
public E smallestValue()
public boolean contains(E target)
target
- the element to search forpublic void add(E value)
value
- the value to add to the treepublic void remove(E value)
value
- the value to remove from the tree.public java.lang.String toString()
toString
in class java.lang.Object
public static void main(java.lang.String[] args)