Data Structures

Data Structures - TreeBalancing:AVLTrees Dr.YingwuZhu...

Info iconThis preview shows pages 1–7. 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 mathematician
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!
Background image of page 6
Image of page 7
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 Fall '11 term at UH Clear Lake.

Page1 / 25

Data Structures - TreeBalancing:AVLTrees Dr.YingwuZhu...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online