{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

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

View Full Document Right Arrow Icon
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.
Background image of page 1

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

View Full Document Right Arrow Icon
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
Background image of page 2
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) n(H) > n(H - 1) + n(H - 2) (we eliminate ethe 1)
Background image of page 3

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

View Full Document Right Arrow Icon
Background image of page 4
Background image of page 5

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

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

{[ snackBarMessage ]}