This preview shows pages 1–5. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Splay Trees
Selfbalancing BST
Invented by Daniel Sleator and Bob Tarjan
Allows quick access to recently accessed
elements D. Sleator Bad: worstcase O(n)
Good: average (amortized) case O(log n)
Often perform better than other BSTs in
practice
R. Tarjan CSE 2011
Prof. J. Elder  31  Last Updated: 4/1/10 2:37 PM Splaying
Splaying is an operation performed on a node that
iteratively moves the node to the root of the tree.
In splay trees, each BST operation (find, insert, remove)
is augmented with a splay operation.
In this way, recently searched and inserted elements are
near the top of the tree, for quick access. CSE 2011
Prof. J. Elder  32  Last Updated: 4/1/10 2:37 PM 3 Types of Splay Steps
Each splay operation on a node consists of a sequence
of splay steps.
Each splay step moves the node up toward the root by 1
or 2 levels.
There are 2 types of step:
ZigZig
ZigZag
Zig CSE 2011
Prof. J. Elder  33  Last Updated: 4/1/10 2:37 PM ZigZig
Performed when the node x forms a linear chain with its
parent and grandparent.
i.e., rightright or leftleft
x z
y y
T4 x
T3
T1 T1
T2 T2 CSE 2011
Prof. J. Elder z zigzig T3  34  T4 Last Updated: 4/1/10 2:37 PM ZigZag
Performed when the node x forms a nonlinear chain
with its parent and grandparent
i.e., rightleft or leftright
z x
y z zigzag y x T1 T4
T2 T1 T2 T3 T4 T3 CSE 2011
Prof. J. Elder  35  Last Updated: 4/1/10 2:37 PM ...
View
Full
Document
This note was uploaded on 02/14/2012 for the course CSE 2011Z taught by Professor Elder during the Fall '11 term at York University.
 Fall '11
 Elder
 Data Structures

Click to edit the document details