Search Trees

Definition

A search tree is a tree in which each node is of the form [t0 a1 t1 a2 t2 ... ak tk ] where k ≥ 0 and a1 through ak comprise an ordered sequence of items and each ti is a search tree with all values between ai and ai+1.

searchtree.gif

Oops. That definition wasn't precise enough. There's no a0 nor ak+1.

Operations

A search tree is intended to be a data structure that represents a set or a dictionary, so the operations on the tree are those of the set or dictionary types. What we really care about are the algorithms used to implement the operations.

Hopefully the algorithm for lookup is pretty obvous by looking at the example. Insertion and deletion algorithms are pretty non-deterministic, unless you decide to put a bound on the number of elements in a node and introducing some balancing requirements.

Performance

If you're lucky and your search tree is short and fat, you should be able to get logarithmic time for lookups on average. If you're not lucky, and your search trees are degenerate (meaning tall and thin), expect linear time.

Some degenerate trees:

degenerate.gif

Certain kinds of search trees, like (a,b)-trees, AVL trees, and Red-Black trees, are defined in such a way as to never become degenerate.