This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: [email protected] TA: f , [email protected] project f : ftp://ds_student:[email protected] 4.4 AVL Trees Target : Speed up searching (with insertion and deletion) Tool : Binary search trees root small large Problem : Although T p = O( height ), but the height can be as bad as O( N ). AVL Trees . Example . 3 binary search trees obtained for the months of the year Nov Oct Sept May Mar June July Dec Aug Apr Feb Jan July June Mar May Oct Sept Nov Jan Feb Aug Apr Dec Entered from Jan to Dec A balanced tree Average search time = ? 3.5 Average search time = ? 3.1 What if the months What if the months are entered in are entered in alphabetical order? alphabetical order? AST = 6.5 AST = 6.5 AVL Trees AdelsonVelskiiLandis (AVL) Trees (1962) AdelsonVelskiiLandis (AVL) Trees (1962) Definition S An empty binary tree is height balanced. If T is a nonempty binary tree with T L and T R as its left and right subtrees, then T is height balanced iff (1) T L and T R are height balanced, and (2)  h L h R  1 where h L and h R are the heights of T L and T R , respectively....
View
Full Document
 Winter '08
 YueChen
 Binary Search

Click to edit the document details