Documente Academic
Documente Profesional
Documente Cultură
Motivating Example
Root
Root
15
2
6
3
18
12
9
14
Initial tree
12
After Search(12)
Splay idea: Get 12
up to the root
using rotations
15
6
3
14
18
P
X
1. zig
P
X
2. zig-zig
G
P
X
3. zig-zag
X
4. zag-zig
X
5. zag-zag
6. zag
3
zig, zag
zig-zig, zig-zag
zag-zig, zag-zag
6
3
12
Zig-Right
15
3
12
18
15
18
6
12
3
1
Zig-Right
12
15
Zig-Right
18
15
12
18
15
18
6
12
3
10
6
14
18
12
14
12
Zig-Right
15
Zag-Left
15
10
14
18
10
15
20
15
Zig-Right
17
Zag-Left
15
17
6
30
17
16
18
20
16
18
20
16
18
30
30
15
15
20
6
17
30
25
20
Zag-Left
40
Zag-Left
30
30
17
25
20
15
40
6
40
25
17
6
15
3
12
Zag-Left
18
18
6
3
12
70
75
60
40
30
65
55
After Zig-zig
(b)
75
60
45
55
60
45
80
50
75
50
30
55
45
(a)
40
70
30
85
70
50
40
85
65
65
After Zig-zig
(c)
11
40
30
70
30
75
60
45
55
60
85
45
55
65
75
65
After Zig-zag
(a)
40
70
50
80
50
60
(b)
30
80
45
70
50
65
55
80
85
75
85
After zag
(c)
12
Do it yourself exercise
13
This guarantees that even if the depths of some nodes get very
large, you cannot get a long sequence of O(N) searches because
each search operation causes a rebalance.