DS-chapter4(AVL Tree)

DS-chapter4(AVL Tree) - fengyan@zju.edu.cn TA: ,...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: fengyan@zju.edu.cn TA: , simonq@zju.edu.cn project : ftp://ds_student:ds_student@10.214.21.68 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 Adelson-Velskii-Landis (AVL) Trees (1962) Adelson-Velskii-Landis (AVL) Trees (1962) Definition 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...
View Full Document

Page1 / 11

DS-chapter4(AVL Tree) - fengyan@zju.edu.cn TA: ,...

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

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