cs251-week9

cs251-week9 - = 1 max(height(l height(r So Heights Nodes 1...

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

View Full Document Right Arrow Icon
AVL Trees An AVL tree is a balanced binary tree. For every internal node v of T, the heights of the children of v can differ at most by 1. 44 17 78 32 50 88 48 62 height(leaf) = 0 height(x) = 1 + max(height(l), height(r)) x is not a leaf So height(y) = 0 then y is a leaf
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: = 1 + max(height(l), height(r)) So: Heights Nodes 1 32, 48, 62, 88 2 17, 50 3 78 4 44 By making sure that the height of the children differ by at most one, we make sure that the height is O(log n) Assume unbalanced tree where height is not O(log n)...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online