Splay Trees

1 / 18

# Splay Trees - PowerPoint PPT Presentation

Splay Trees. Sean Lyn April 3, 2008. What is it?. A binary tree structure that is very similar to other trees but with additional properties. Has the potential for speeds faster than O(logn).

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

## PowerPoint Slideshow about 'Splay Trees' - jack

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

### Splay Trees

Sean Lyn

April 3, 2008

What is it?
• A binary tree structure that is very similar to other trees but with additional properties.
• Has the potential for speeds faster than O(logn).
• Its bounds are amortized – even though individual operations may be expensive, any sequence of operations is guaranteed to behave as though each operation had logarithmic behavior.
Differences
• Balanced trees require an extra piece of balancing information.
• Balanced trees have expensive insertion and deletion.
• Splay trees take advantage of the 90-10 rule.
Splaying
• Splaying is the process of rotating the most currently used node to the root.
• Two types of trees: Bottom Up and Top Down.
Bottom Up Splay Trees
• Three Cases: Zig, Zig-Zag, and Zig-Zig
• Zig occurs when X is a non-root and P is the root. In this case we rotate X to the root.
• Zig-Zag occurs when X has a parent P and a grandparent G where X is a right child and P is a left child or vice versa.
• Zig-Zig occurs when X and its parent P are both left or right children.
Zig
• Single rotation involving X and P
Zig-Zag
• Double rotation similar to an AVL tree. First we rotate X and P, then X and G to bring X to the root.
Zig-Zig
• Uses a double rotation by first rotating P and G then rotating X and P
Splay Tree Operations
• A splay operation is performed after every access to a node.
• Find – splay the tree after finding it
• DeleteMin is simple, perform FindMin which will bring it to the top then the right child becomes the new root.
• Removal – Access the node which makes it the root then delete it which gives two trees. Find the max of the left tree and that is the new root.
Top Down Splay Trees
• Works by starting at the top and working down to produce a similar result.
• All of the nodes lower than the target are put into one tree and all of the nodes greater than the target are put into another tree then it is recombined.
Conclusion
• Are Splay Trees better to use? The answer has no been resolved completely.
• They situationally perform better than other balanced trees, usually determined by the access patterns.
Questions
• What is one unique property of a splay tree?
• What are the three cases for rotating a node to the root?
Sources
• Weiss, Mark. Data Structures and Problem Solving Using Java. Boston: Pearson Education, Inc, 2006.