avl trees height balance avl trees
play

AVL TREES Height Balance : AVL Trees h 1 h 2 | h - h | 1 AVL - PDF document

AVL TREES Height Balance : AVL Trees h 1 h 2 | h - h | 1 AVL AVL 2 1 non-AVL trees AVL trees S. Prasitjutrakul 1994 AVL Trees : I nsertion m m k k k u u k k m m v t u m m t t u k m u k u p v t k p v v


  1. AVL TREES

  2. Height Balance : AVL Trees h 1 h 2 | h - h | ≤ 1 AVL AVL 2 1 non-AVL trees AVL trees S. Prasitjutrakul 1994

  3. AVL Trees : I nsertion m m k k k u u k k m m v t u m m t t u k m u k u p v t k p v v p Rotations S. Prasitjutrakul 1994

  4. Rotations : Right High (Left Rotation) r x x r h A C h +1 h B h C h +1 B h A Total height = h +3 Total height = h +2 S. Prasitjutrakul 1994

  5. Rotations : Left High (Double Rotation) r w x x r h A w D D h B h C h h A h B h C h Total height = h +2 Total height = h +3 S. Prasitjutrakul 1994

  6. Rotations : Left High (Double Rotation) r w x x r h A w D D h B h h h A h -1 C B h C h -1 Total height = h +2 Total height = h +3 S. Prasitjutrakul 1994

  7. Rotations : Left High (Double Rotation) r w x x r h A w D D h B h -1 C h h A h B C h h -1 Total height = h +2 Total height = h +3 S. Prasitjutrakul 1994

  8. Deletion from an AVL Tree p p p p A A A B A B B B p q q p A C A B B C S. Prasitjutrakul 1994

  9. Deletion from an AVL Tree q p p q A C B A B C p q r p r A q C B D D A B C S. Prasitjutrakul 1994

  10. Deletion : Example m deleted e p c j s n b h d k r u o g l a i t f S. Prasitjutrakul 1994

  11. Deletion : Example m e o p c j s n n s b h d k r u r o l g a i t f deleted S. Prasitjutrakul 1994

  12. Deletion : Example m m o o s s n n r u r u t t A A deleted shorter S. Prasitjutrakul 1994

  13. Deletion : Example m m s o u s o n n r r u t t A A shorter shorter S. Prasitjutrakul 1994

  14. Deletion : Example m e s c j u o b h d k n r t l g a i f S. Prasitjutrakul 1994

  15. Deletion : Example j e m c s h k b d g u i l o f a n r t S. Prasitjutrakul 1994

  16. The Height of an AVL Tree กํ าหนดให F คือ AVL tree ที่มีความสูง h ที่มีจํ านวน nodes นอยที่สุด h และให | F | คือจํ านวน nodes ของตนไม F h h F h F h F h F h Fibonacci Tree worst-case bound S. Prasitjutrakul 1994

Recommend


More recommend