In classes 15 and 16 we examined Binary Search Trees. We saw that the running time of such common operations as Find and Insert was O(n) in the worst case, and O(lg n) in the best case. We also examined the "average" case across all BSTs with n nodes and found the "average" time to be O(lg n), but this is not the same as saying the running time is O(lg n) for all BSTs.

We will now examine ways to guarantee O(lg n) running time for these operations in all BSTs.
The first of these mechanisms is called a "Splay" Tree. Splay trees do not guarantee that every operation will be O(lg n), but instead strive to make the amortized running time of m operations be O (m lg n). Some operations will be as bad as O(n), but over time, O(lg n) running time is achieved.

Notes for class 17 are available in both HTML and postscript formats.