14-1. AVLTrees_outside

17 78 32 50 4 8 62 2 5 1 1 3 4 2 1 54 1 t t 2 t 3 x y

Info iconThis preview shows pages 6–11. 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 Document Right Arrow Icon

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

View Full Document Right Arrow Icon

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

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

Unformatted text preview: 17 78 32 50 4 8 62 2 5 1 1 3 4 2 1 54 1 T T 2 T 3 x y z 2 3 4 5 6 7 1 88 44 17 78 32 50 48 62 2 4 1 1 2 2 3 1 54 1 T T 1 T 2 T 3 x y z unbalanced... ...balanced 1 2 3 4 5 6 7 T 1 © 2004 Goodrich, Tamassia AVL Trees 7 Restructuring (as Single Rotations) Single Rotations: T T 1 T 2 T 3 c = x b = y a = z T T 1 T 2 T 3 c = x b = y a = z single rotation T 3 T 2 T 1 T a = x b = y c = z T T 1 T 2 T 3 a = x b = y c = z single rotation © 2004 Goodrich, Tamassia AVL Trees 8 Restructuring (as Double Rotations) double rotations: double rotation a = z b = x c = y T T 2 T 1 T 3 T T 2 T 3 T 1 a = z b = x c = y double rotation c = z b = x a = y T T 2 T 1 T 3 T T 2 T 3 T 1 c = z b = x a = y © 2004 Goodrich, Tamassia AVL Trees 9 Removal Removal begins as in a binary search tree, which means the node removed will become an empty external node. Its parent, w, may cause an imbalance. Example: 44 17 78 32 50 88 48 62 54 44 17 78 50 88 48 62 54 before deletion of 32 after deletion © 2004 Goodrich, Tamassia AVL Trees...
View Full Document

{[ snackBarMessage ]}

Page6 / 11

17 78 32 50 4 8 62 2 5 1 1 3 4 2 1 54 1 T T 2 T 3 x y z 2 3...

This preview shows document pages 6 - 11. Sign up to view the full document.

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