notes79

# notes79 - AVL Trees An AVL tree is a balanced binary tree...

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

AVL Trees - An AVL tree is a balanced binary tree. - It is used as a dictionary to map key->data. - The insert/remove operations need to maintain the tree's balance. Height of a node height(x) = 0 if x is a leaf node 1 + max ( height( x->left ), height( x->right ) ) Example: An AVL tree is a balanced binary tree if for every internal node v, the heights of the children of v can differ by 1. The tree above is a balanced binary tree.

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

View Full Document
Not a balanced binary tree! Proposition The height (of the root) of an AVL tree T is O(log n) where n is the number of nodes. Proof: Keeping H constant, find the minimum number n of internal nodes that we can fit in a balanced AVL tree. n(H) = minimum number of internal nodes of an AVL tree of height H. n(1) = 1
n(2) = 2 n(H) = n(H - 1) + n(H - 2) + 1 For H >= 3, the AVL with heigh H, the minimum number of nodes contains a subtree of height H-1 and another subtree with height H-2 with the minimum number of nodes. (balanced tree with minimum number of nodes with height H)

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 02/02/2012 for the course CS 251 taught by Professor Staff during the Fall '08 term at Purdue.

### Page1 / 6

notes79 - AVL Trees An AVL tree is a balanced binary tree...

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

View Full Document
Ask a homework question - tutors are online