Splay tree

Splay tree
TypeTree
Invented1985
Invented byDaniel Dominic Sleator and Robert Endre Tarjan
Complexities in big O notation
Space complexity
Space O(n)
Time complexity
Function Amortized Worst Case
Search O(log n)[1]: 659  O(n)[2]: 1 
Insert O(log n)[1]: 659  O(n)
Delete O(log n)[1]: 659  O(n)

A splay tree is a binary search tree with the additional property that recently accessed elements are quick to access again. Like self-balancing binary search trees, a splay tree performs basic operations such as insertion, look-up and removal in O(log n) amortized time. For random access patterns drawn from a non-uniform random distribution, their amortized time can be faster than logarithmic, proportional to the entropy of the access pattern. For many patterns of non-random operations, also, splay trees can take better than logarithmic time, without requiring advance knowledge of the pattern. According to the unproven dynamic optimality conjecture, their performance on all access patterns is within a constant factor of the best possible performance that could be achieved by any other self-adjusting binary search tree, even one selected to fit that pattern. The splay tree was invented by Daniel Sleator and Robert Tarjan in 1985.[1]

All normal operations on a binary search tree are combined with one basic operation, called splaying. Splaying the tree for a certain element rearranges the tree so that the element is placed at the root of the tree. One way to do this with the basic search operation is to first perform a standard binary tree search for the element in question, and then use tree rotations in a specific fashion to bring the element to the top. Alternatively, a top-down algorithm can combine the search and the tree reorganization into a single phase.

  1. ^ a b c d Sleator & Tarjan 1985.
  2. ^ Cite error: The named reference BrinkmannDegraerDeLoof was invoked but never defined (see the help page).