public class BinarySearchTree
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
BinarySearchTree.BinaryNode |
| Constructor and Description |
|---|
BinarySearchTree() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
contains(int value)
Time complexity: O(logn) if the tree is balanced, O(n) in the worst case
|
void |
insert(int value)
Time complexity: O(logn) if the tree is balanced, O(n) in the worst case
|
BinarySearchTree.BinaryNode |
maximum()
Time complexity: O(logn) if the tree is balanced, O(n) in the worst case
|
BinarySearchTree.BinaryNode |
minimum()
Time complexity: O(logn) if the tree is balanced, O(n) in the worst case
|
void |
remove(BinarySearchTree.BinaryNode node)
Time complexity: O(logn) if the tree is balanced, O(n) in the worst case
|
BinarySearchTree.BinaryNode |
search(int value)
Time complexity: O(logn) if the tree is balanced, O(n) in the worst case
|
int |
size()
Time complexity: Θ(1)
|
public void insert(int value)
public BinarySearchTree.BinaryNode search(int value)
public void remove(BinarySearchTree.BinaryNode node)
public boolean contains(int value)
public int size()
public BinarySearchTree.BinaryNode minimum()
public BinarySearchTree.BinaryNode maximum()