AVLTree-102-sp10

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

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

View Full Document Right Arrow Icon
AVL Trees Data Structures Fall 2008 Evan Korth Adopted from a presentation by Simon Garrett and the Mark Allen Weiss book
Background image of page 1

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

View Full DocumentRight Arrow Icon
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
Background image of page 2
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
Background image of page 3

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

View Full DocumentRight Arrow Icon
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
Background image of page 4
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’
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.

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 Right Arrow Icon
Ask a homework question - tutors are online