public class BinarySearchTree<K extends java.lang.Comparable<K>,V>
extends java.lang.Object
| Constructor and Description |
|---|
BinarySearchTree() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(K key,
V data) |
static BinarySearchTree<java.lang.Integer,java.lang.String> |
createBalancedTree() |
int |
getInteriorNodesCount()
This method computes the number of interior nodes in the tree.
|
int |
getLeavesCount()
This method computes the number of leave nodes in the tree.
|
int |
getMaximum()
This method computes the maximum key value in the tree.
|
static void |
main(java.lang.String[] args) |
boolean |
same(BinarySearchTree tree)
This method determines whether the parameter and the current object tree
have the same keys (ignore the values the key are mapped to).
|
boolean |
sameShape(BinarySearchTree tree)
This method determines whether the parameter and the current object tree
have the same shape (we don't care about keys/values).
|
int |
size()
This method computes the tree size.
|
java.lang.String |
toString() |
public static void main(java.lang.String[] args)
public java.lang.String toString()
toString in class java.lang.Objectpublic static BinarySearchTree<java.lang.Integer,java.lang.String> createBalancedTree()
public int getMaximum()
public int size()
public int getLeavesCount()
public int getInteriorNodesCount()
public boolean same(BinarySearchTree tree)
public boolean sameShape(BinarySearchTree tree)