Transcript PPT

CMSC 341
Splay Tree Diagrams
Bottom-Up Splaying
These diagrams show the rotations
necessary for “Bottom-Up” splaying.
Note that these diagrams illustrate the
rotations necessary whenever the node to
be splayed is a left child. Symmetric
rotations are performed when the node is
a right child.
Bottom-Up Single Rotation
Bottom-Up Zig-Zig
Bottom-Up Zig-Zag
G
G
P
A
X
B
X
A
D
P
B
C
C
X
G
A
P
B
C
D
D
Top-Down Splaying
These diagrams illustrate the reorganization
of the splay tree as we follow the left-link
from a node. Note that symmetric
reorganization of the tree occurs when the
right-link is followed.
Top-Down Zig
X
L
R
L
R
Y
X
Y
XR
YL
YL
Yr
Yr
XR
Top-Down Zig-Zig
X
L
R
L
R
Z
Y
Y
XR
Z
ZL
X
Zr
YR
YR
ZL
Zr
XR
Top-Down Zig-Zag
X
L
R
L
R
Y
Y
X
XR
YL
YL
Z
Z
ZL
Zr
ZL
XR
Zr