{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Data Structures

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

This preview shows pages 1–7. 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 mathematician
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!
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern