lecture13 - TreeBalancing:AVLTrees Dr.YingwuZhu RecallinBST

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

View Full Document Right Arrow Icon
Tree Balancing: AVL Trees Dr. Yingwu Zhu
Background image of page 1

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

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

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

View Full DocumentRight Arrow Icon
Determine balance factor A B D G E H F C
Background image of page 4
ADT: AVL Trees Data structure to implement   Balance factor        Data Left Right
Background image of page 5

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

View Full DocumentRight Arrow Icon
ADT: AVL Trees Basic operations Constructor, search, travesal, empty Insert: keep balanced! Delete: keep balanced! See P842 for class template Similar to BST
Background image of page 6
Example RI PA Insert “DE”, what happens?  Need rebalancing?
Background image of page 7

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

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/01/2011 for the course CSSE 250 taught by Professor Dr.yingwuzhu during the Spring '11 term at UH Clear Lake.

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