Splay Trees Data Structures & Problem Solving Using JAVA Second Edition Mark Allen Weiss Chapter 22 © 2002 Addison Wesley
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
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
Figure 22.3 Sequential access of items takes quadratic time Data Structures & Problem Solving using JAVA/2E Mark Allen Weiss © 2002 Addison Wesley
Figure 22.4 The zig case (normal single rotation) Data Structures & Problem Solving using JAVA/2E Mark Allen Weiss © 2002 Addison Wesley
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
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
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
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
Figure 22.9A Top-down splay rotations: (a) zig (continued) Data Structures & Problem Solving using JAVA/2E Mark Allen Weiss © 2002 Addison Wesley
Figure 22.9B Top-down splay rotations: (b) zig-zig (continued) Data Structures & Problem Solving using JAVA/2E Mark Allen Weiss © 2002 Addison Wesley
Figure 22.9C Top-down splay rotations: (c) zig-zag Data Structures & Problem Solving using JAVA/2E Mark Allen Weiss © 2002 Addison Wesley
Figure Simplified top–down zig-zag Data Structures & Problem Solving using JAVA/2E Mark Allen Weiss © 2002 Addison Wesley
Figure Final arrangement for top–down splaying Data Structures & Problem Solving using JAVA/2E Mark Allen Weiss © 2002 Addison Wesley
Figure (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
Figure (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