lecture13

# lecture13 - TreeBalancing:AVLTrees Dr.YingwuZhu RecallinBST...

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

Tree Balancing: AVL Trees Dr. Yingwu Zhu

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

View Full Document
Recall in BST The insertion order of items determine the  shape of BST Balanced: search T(n)=O(logN) Unbalanced: T(n) = O(n) Key issue: A need to keep a BST balanced! Introduce AVL trees, by Russian mathematican
AVL Tree Definition First, a BST Second,  height-balance property balance  factor  of each node is  0 1 , or  -1 Question: what is  balance factor ? BF = Height of the left subtree – height of the right subtree Height: # of levels in a subtree/tree

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

View Full Document
Determine balance factor A B D G E H F C
ADT: AVL Trees Data structure to implement   Balance factor        Data Left Right

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

View Full Document
ADT: AVL Trees Basic operations Constructor, search, travesal, empty Insert: keep balanced! Delete: keep balanced! See P842 for class template Similar to BST
Example RI PA Insert “DE”, what happens?  Need rebalancing?

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.

{[ snackBarMessage ]}

### Page1 / 13

lecture13 - TreeBalancing:AVLTrees Dr.YingwuZhu RecallinBST...

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

View Full Document
Ask a homework question - tutors are online