End of Term Review 1.7

# End of Term Review 1.7 - Splay Trees Self-balancing BST...

This preview shows pages 1–5. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Splay Trees Self-balancing BST Invented by Daniel Sleator and Bob Tarjan Allows quick access to recently accessed elements D. Sleator Bad: worst-case O(n) Good: average (amortized) case O(log n) Often perform better than other BSTs in practice R. Tarjan CSE 2011 Prof. J. Elder - 31 - Last Updated: 4/1/10 2:37 PM Splaying Splaying is an operation performed on a node that iteratively moves the node to the root of the tree. In splay trees, each BST operation (find, insert, remove) is augmented with a splay operation. In this way, recently searched and inserted elements are near the top of the tree, for quick access. CSE 2011 Prof. J. Elder - 32 - Last Updated: 4/1/10 2:37 PM 3 Types of Splay Steps Each splay operation on a node consists of a sequence of splay steps. Each splay step moves the node up toward the root by 1 or 2 levels. There are 2 types of step: Zig-Zig Zig-Zag Zig CSE 2011 Prof. J. Elder - 33 - Last Updated: 4/1/10 2:37 PM Zig-Zig Performed when the node x forms a linear chain with its parent and grandparent. i.e., right-right or left-left x z y y T4 x T3 T1 T1 T2 T2 CSE 2011 Prof. J. Elder z zig-zig T3 - 34 - T4 Last Updated: 4/1/10 2:37 PM Zig-Zag Performed when the node x forms a non-linear chain with its parent and grandparent i.e., right-left or left-right z x y z zig-zag y x T1 T4 T2 T1 T2 T3 T4 T3 CSE 2011 Prof. J. Elder - 35 - Last Updated: 4/1/10 2:37 PM ...
View Full Document

## This note was uploaded on 02/14/2012 for the course CSE 2011Z taught by Professor Elder during the Fall '11 term at York University.

### Page1 / 5

End of Term Review 1.7 - Splay Trees Self-balancing BST...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online