lecture06AVL

lecture06AVL - AVL Trees Keep BST in balance(efficient...

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

1 AVL Trees Keep BST in balance (efficient) Checking/Tracking balance Adelson-Velskii and Landis (AVL) tree Insert Delete

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

View Full Document
2 Good Trees and Bad Trees d = Θ (log n) d = Θ (n)
3 Balancing Search Tree AVL Tree for every node in the tree, the height of the left and right subtree can differ by at most 1. How to keep it balanced? Rotation (single, or double) average depth and worst case depth are O(logN) Splay Tree life time total complexity for m operations is O(MlogN), where N is the size of the tree simple to implement B Tree each nodes has between 2 and M children good for external storage (disks etc.) data structures

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

View Full Document
4 How to Avoid Bad Trees?
5 Idea #1 The left and right subtrees have the same height. Too weak

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

View Full Document
6 Idea #2 For every node in the tree, the left and right subtrees of that node have the same height (or the same number of children) Too rigid (2 k -1 nodes)
7 Testing balanced Is_Balanced(T, height) if T = nil height ← -1 return true

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 ]}

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