|
ADS
Algorithms and Data Structures
|
The splay tree of Sleator and Tarjan, beyond the book: a binary search tree with no balance information, where each access moves the node accessed to the root by rotations in pairs (zig-zig and zig-zag), which roughly halve the depth of the nodes on its path; any sequence of \( m \) operations on \( n \) keys takes \( O( ( m + n ) \log n ) \) time, i.e., \( O( \log n ) \) amortized each, and the keys accessed often stay near the root (the static optimality and the working set theorems). More...
#include "ADS/Contract.h"#include "ADS/Iterators.h"#include <concepts>#include <cstddef>#include <memory>#include <optional>#include <utility>#include <vector>#include "ADS/tree/impl/SplayTree.tpp"Go to the source code of this file.
Classes | |
| class | ADS::SplayTree< K, V > |
| a DICTIONARY on a splay tree More... | |
| struct | ADS::SplayTree< K, V >::Shape |
| the shape of the tree, for PathIterator More... | |
Namespaces | |
| namespace | ADS |
The splay tree of Sleator and Tarjan, beyond the book: a binary search tree with no balance information, where each access moves the node accessed to the root by rotations in pairs (zig-zig and zig-zag), which roughly halve the depth of the nodes on its path; any sequence of \( m \) operations on \( n \) keys takes \( O( ( m + n ) \log n ) \) time, i.e., \( O( \log n ) \) amortized each, and the keys accessed often stay near the root (the static optimality and the working set theorems).
The splay is top-down, in one pass from the root that splits the tree into a left and a right part and joins them at the end. It is a DICTIONARY [see ADT.h]; lookup() also splays, hence it changes the shape of the tree (but not its keys) and is not const.
The contracts [see Contract.h]: insert() ensures that the key is there, at the root, and remove() that it is not; the invariant is the order of the keys, an \( O( n ) \) check at the level 3. The operations are defined in SplayTree.tpp.