Splay Trees

An implementation of splay trees where insert, member, front and back rotate the inserted/accessed node to the root using splaying. When erasing a node, the node being erased is splayed to the root and then erased using the normal binary search tree removal.

In a departure from the liturature, there are six operations:

  • zig-zig
  • zig-zag
  • zag-zig
  • zag-zag
  • zig
  • zag

The term "zig" indicates an insertion/access to the left while the term "zag" indicates an insertion/access to the right. Rather than implementing the rotations as pairs of single rotations, each is implemented as a reordering of the required pointer values. In each case, it is relatively easy to reduce the number of assignments; however, for clarity, the sub-trees to be modified are temproarily stored and then reassigned.