Search Trees_Part_9

Search Trees_Part_9 - Running Times for AVL Trees a single...

Info iconThis preview shows page 1. Sign up to view the full content.

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

Unformatted text preview: Running Times for AVL Trees a single restructure is O(1) using a linked-structure binary tree find is O(log n) height of tree is O(log n), no restructures needed insert is O(log n) initial find is O(log n) Restructuring is O(1) remove is O(log n) initial find is O(log n) Restructuring up the tree, maintaining heights is O(log n) CSE 2011 Prof. J. Elder - 41 - Last Updated: 3/3/10 6:14 PM Splay Trees 6 v 8 3 z 4 CSE 2011 Prof. J. Elder - 42 - Last Updated: 3/3/10 6:14 PM 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 - 43 - Last Updated: 3/3/10 6:14 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 - 44 - Last Updated: 3/3/10 6:14 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 - 45 - Last Updated: 3/3/10 6:14 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.

Ask a homework question - tutors are online