1 / 18

Splay Trees

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).

jack
Télécharger la présentation

Splay Trees

An Image/Link below is provided (as is) to download presentation 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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Splay Trees Sean Lyn April 3, 2008

  2. 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. • Self adjusting.

  3. 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.

  4. Splaying • Splaying is the process of rotating the most currently used node to the root. • Two types of trees: Bottom Up and Top Down.

  5. 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.

  6. Zig • Single rotation involving X and P

  7. 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.

  8. Zig-Zig • Uses a double rotation by first rotating P and G then rotating X and P

  9. Zig-Zig

  10. 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.

  11. Deletion on 6

  12. 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.

  13. Top Down Splaying

  14. Top Down Splaying

  15. Top Down Splaying

  16. 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.

  17. Questions • What is one unique property of a splay tree? • What are the three cases for rotating a node to the root?

  18. Sources • Weiss, Mark. Data Structures and Problem Solving Using Java. Boston: Pearson Education, Inc, 2006.

More Related