Download presentation
Presentation is loading. Please wait.
Published byNathan Bishop Modified over 9 years ago
1
Splay Trees Data Structures & Problem Solving Using JAVA Second Edition Mark Allen Weiss Chapter 22 © 2002 Addison Wesley
2
Figure 22.1 Rotate-to-root strategy applied when node 3 is accessed Data Structures & Problem Solving using JAVA/2E Mark Allen Weiss © 2002 Addison Wesley
3
Figure 22.2 Insertion of 4 using the rotate-to-root strategy Data Structures & Problem Solving using JAVA/2E Mark Allen Weiss © 2002 Addison Wesley
4
Figure 22.3 Sequential access of items takes quadratic time Data Structures & Problem Solving using JAVA/2E Mark Allen Weiss © 2002 Addison Wesley
5
Figure 22.4 The zig case (normal single rotation) Data Structures & Problem Solving using JAVA/2E Mark Allen Weiss © 2002 Addison Wesley
6
Figure 22.5 The zig-zag case (same as a double rotation); the symmetric case has been omitted Data Structures & Problem Solving using JAVA/2E Mark Allen Weiss © 2002 Addison Wesley
7
Figure 22.6 Zig-zig case (unique to the splay tree); the symmetric case has been omitted Data Structures & Problem Solving using JAVA/2E Mark Allen Weiss © 2002 Addison Wesley
8
Figure 22.7 Result of splaying at node 1 (three zig-zigs) Data Structures & Problem Solving using JAVA/2E Mark Allen Weiss © 2002 Addison Wesley
9
Figure 22.8 The remove operation applied to node 6: First, 6 is splayed to the root, leaving two subtrees; a findMax is performed on the left subtree, raising 5 to the root of the left subtree; then the right subtree can be attached (not shown). Data Structures & Problem Solving using JAVA/2E Mark Allen Weiss © 2002 Addison Wesley
10
Figure 22.9A Top-down splay rotations: (a) zig (continued) Data Structures & Problem Solving using JAVA/2E Mark Allen Weiss © 2002 Addison Wesley
11
Figure 22.9B Top-down splay rotations: (b) zig-zig (continued) Data Structures & Problem Solving using JAVA/2E Mark Allen Weiss © 2002 Addison Wesley
12
Figure 22.9C Top-down splay rotations: (c) zig-zag Data Structures & Problem Solving using JAVA/2E Mark Allen Weiss © 2002 Addison Wesley
13
Figure 22.10 Simplified top–down zig-zag Data Structures & Problem Solving using JAVA/2E Mark Allen Weiss © 2002 Addison Wesley
14
Figure 22.11 Final arrangement for top–down splaying Data Structures & Problem Solving using JAVA/2E Mark Allen Weiss © 2002 Addison Wesley
15
Figure 22.12 (A) Steps in a top–down splay (accessing 19 in the top tree) (continued) Data Structures & Problem Solving using JAVA/2E Mark Allen Weiss © 2002 Addison Wesley
16
Figure 22.12 (B) Steps in a top–down splay (accessing 19 in the top tree) (continued) Data Structures & Problem Solving using JAVA/2E Mark Allen Weiss © 2002 Addison Wesley
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.