splay6 - Advanced Tree Structures Splay Trees (6)...

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

View Full Document Right Arrow Icon
Introduction A common application of AVL trees and red-black trees is the implementation of dictionaries. The most common dictionary operations are searching, insertion, and deletion. A dictionary is a collection of pairs of the form ( k, e ), where k is a key and e is the element associated with the key k . (equivalently, e is the element whose key is k ), In most forms of dictionaries, no two pairs will have the same key. The following operations are defined on a dictionary: get (k, e) : Get the element e associated with key k from the dictionary. This operation is equivalent to a search in the dictionary. put (k, e) Put the element e associated with key k into the dictionary. This operation is equivalent to an insertion into the dictionary. remove (k, e) Remove the element e associated with key k from the dictionary. This operation is equivalent to a deletion from the dictionary. No known data structure provides a better worst-case time complexity for these operations than does a dictionary. However, in many applications of a dictionary, we are less concerned with the time required by an individual operation than we are in the time taken by a sequence of operations. This is the case for applications such as histogramming and best-fit bin packing problems (often implemented using search trees with duplicate values). The complexity of these applications depends on the time taken to perform a sequence of dictionary operations, not on the time required for any individual operation. Splay trees are a variation of binary search trees in which the complexity of an individual dictionary operation is O( n ). However, every sequence of get O(g), put O(p), and remove O(r) operations is done in O(( g + p + r ) log p ) time. This is the same asymptotic complexity as when AVL or red-black trees are used. Empirical results have demonstrated that for random sequences of dictionary operations, splay trees are faster than either AVL trees or red-black trees. As an added bonus, splay trees are easier to code and understand. Splay Trees - 1 Advanced Tree Structures – Splay Trees (6)
Background image of page 1

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

View Full DocumentRight Arrow Icon
The Splay Operation The normal search tree operations of searching, insertion, and deletion are performed exactly as they are in a normal binary search tree, however, they are followed by a splay operation that starts at a splay node . When the splay operation terminates, the splay node will have become the root of the search tree. The splay node is selected to be the highest level (i.e., deepest) node, in the resulting tree that was examined (i.e., a comparison was done with the key in this node and the node was either, newly created (insert), removed (delete), or we moved to either the left or right child of this node) during the dictionary operation. Consider the binary search tree shown in Figure 1.
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 06/13/2011.

Page1 / 10

splay6 - Advanced Tree Structures Splay Trees (6)...

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

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