Splay - CSE 4101/5101 Prof. Andy Mirzaian Splay Tree: Self...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
CSE 4101/5101 Splay Tree: Self Adjusting BST Prof. Andy Mirzaian
Background image of page 1

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

View Full DocumentRight Arrow Icon
Lists Move-to-Front Search Trees Binary Search Trees Multi-Way Search Trees B-trees Splay Trees 2-3-4 Trees Red-Black Trees SELF ADJUSTING WORST-CASE EFFICIENT competitive competitive? Linear Lists Multi-Lists Hash Tables DICTIONARIES 2
Background image of page 2
References: Lecture Note 3 AAW animation 3
Background image of page 3

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

View Full DocumentRight Arrow Icon
Self-Adjusting Binary Search trees § Red-Black trees guarantee that each dictionary operation (Search, Insert, Delete) takes O(log n) time in the worst-case . They achieve this by enforcing an explicit “balance” constraint on the tree. § Can we endow self-adjusting feature to the standard BST by the use of appropriate rotations to restructure the tree and improve the efficiency of future operations in order to keep the amortized cost per operation low? Is there a simple self-adjusting data structure that guarantees O(log n) amortized time per dictionary operation? YES , Splay trees . § As with Red-Black trees, Splay trees give the following guarantee: Any sequence of m dictionary operations on an initially empty dictionary takes in total O(m log n) time, where n is the max size of the dictionary during this sequence. However, a single dictionary operation on Splay trees in the worst-case may cost up to Θ (n) time. § Splay Trees maintain a BST in an arbitrary state, with no “balance” information/constraint. However, they perform the simple, uniformly defined, splay operation after each dictionary operation. A splay operation on BSTs is analogous to Move-to-Front on linear lists. 4
Background image of page 4
§ GenericSplay(x): Consider the links on the search path of node x in BST T. This operation performs one rotation per link on this path in some appropriate order to move node x up to the root of T. § The number of rotations (at a cost of O(1) per rotation) done by GenericSplay(x) is depthT(x), i.e., depth of x in T before the splay. Access cost of node x is O(1+ depthT(x)). § Generic Splay tree: This is an arbitrary BST such that after each dictionary operation we perform GenericSplay(x), where x is the deepest node accessed by the dictionary operation that is still in the tree. The cost of the dictionary operation, including the splay, is O(1+depth(x)). Which node is x? Ø Successful search: x is the node just accessed. Ø Unsuccessful search: x is parent of the external node just accessed. Ø Insert: x is the node now holding the insertion key. Ø Unsuccessful Delete: same as unsuccessful search. Ø Successful Delete: x is parent of the spliced-out node. § Any sequence of m dictionary operations takes O(m+R) time, where R is the total number of rotations done by the generic splay operations in the sequence. So, we need to find an upper bound on R. 5
Background image of page 5

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

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/13/2012 for the course CSE 4101 taught by Professor Mirzaian during the Winter '12 term at York University.

Page1 / 27

Splay - CSE 4101/5101 Prof. Andy Mirzaian Splay Tree: Self...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online