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

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

View Full Document Right Arrow Icon
1 AVL Trees Keep BST in balance (efficient) Checking/Tracking balance Adelson-Velskii and Landis (AVL) tree Insert Delete
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 Good Trees and Bad Trees d = Θ (log n) d = Θ (n)
Background image of page 2
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
Background image of page 3

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

View Full DocumentRight Arrow Icon
4 How to Avoid Bad Trees?
Background image of page 4
5 Idea #1 The left and right subtrees have the same height. Too weak
Background image of page 5

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

View Full DocumentRight Arrow Icon
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)
Background image of page 6
7 Testing balanced Is_Balanced(T, height) if T = nil height ← -1 return true
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 07/25/2008 for the course CSE 331 taught by Professor M.mccullen during the Spring '08 term at Michigan State University.

Page1 / 27

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

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