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.
7/26/2016
2
Bottom-Up Single Rotation
7/26/2016
3
Bottom-Up Zig-Zig
7/26/2016
4
Bottom-Up Zig-Zag
G
G
P
A
X
B
X
A
D
P
B
C
C
D
X
G
A
7/26/2016
P
B
C
D
5
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.
7/26/2016
6
Top-Down Zig
X
L
R
L
R
Y
X
Y
XR
YL
YL
7/26/2016
Yr
Yr
XR
7
Top-Down Zig-Zig
X
L
R
L
R
Z
Y
Y
XR
Z
ZL
X
Zr
YR
YR
ZL
7/26/2016
XR
Zr
8
Top-Down Zig-Zag
X
L
L
R
Y
Y
X
XR
YL
YL
Z
Z
ZL
7/26/2016
R
Zr
ZL
XR
Zr
9