Splay Trees
Splay Trees
Splay Trees
Introduction
• Splay trees support all the operations of binary trees.
• But they do not guarantee Ο(log N ) worst-case performance.
• Instead, its bounds are amortized, meaning that although individual operations can be
expensive, any sequence of operations is guaranteed to behave as if each operation in the
sequence exhibited logarithmic behavior.
• When nodes are rotated to the root, other nodes go to lower levels in the tree.
• If we do not have the 90-10 rule, it is possible for a long sequence of bad accesses to
occur.
• Given the rotations, consider the example in Figure 5, where we are splaying c.
Figure 7 Zig
o Zig-Zig – Figure 8
Figure 8 Zig-Zig
o Zig-Zag – Figure 9
Figure 10 Reassembling