AVLTree-102-sp10

# AVLTree-102-sp10 - AVL Trees Data Structures Fall 2008 Evan...

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

AVL Trees Data Structures Fall 2008 Evan Korth Adopted from a presentation by Simon Garrett and the Mark Allen Weiss book

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

View Full Document
AVL (Adelson-Velskii and Landis) tree A balanced binary search tree where the height of the two subtrees (children) of a node differs by at most one. Look-up, insertion, and deletion are O( log n), where n is the number of nodes in the tree. http://www.cs.jhu.edu/~goodrich/dsa/trees/av Source: nist.gov
Definition of height (reminder) Height: the length of the longest path from a node to a leaf. All leaves have a height of 0 An empty tree has a height of –1

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

View Full Document
The insertion problem Unless keys appear in just the right order, imbalance will occur It can be shown that there are only two possible types of imbalance (see next slide): Left-left (or right-right) imbalance Left-right (or right-left) imbalance The right-hand imbalances are the same, by symmetry
The two types of imbalance Left-left (right-right) Left-right (right-left) 2 1 A B C 2 1 A C B Left imbalance There are no other possibilities for the left (or right) subtree so-called ‘dog-leg’

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.

## This note was uploaded on 05/06/2010 for the course COMPUTER S 101 taught by Professor Sanaodeh during the Spring '08 term at NYU.

### Page1 / 18

AVLTree-102-sp10 - AVL Trees Data Structures Fall 2008 Evan...

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

View Full Document
Ask a homework question - tutors are online