{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

Info icon This 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)
Image of page 1

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

View Full Document Right 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.
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern