Definition: A binary search tree is a binary tree where each node has a Comparble key (and an associated value) and satisfies the restriction that the key in any node is larger than all the keys in nodes in its left subtree and smaller than all the keys in the nodes in its right subtree.
An ordered symbol table based on a binary search tree potentially has the advantages of both the ordered array implementation (BinarySearchST) and the linked list implementation (SequentialSearchST) without the disadvantages:
Advantages
- BinarySearchST: Fast searches: O(log(N))
- SequentialSearchST: Insertion doesn't require moving other key,value pairs.
Disadvantages
- BinarySearchST: Insertion can require O(N) moving of (key,value) pairs.
- SeqentialSerachST: Slow searches: O(log(N)) on average.