{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

14-1. AVLTrees_outside

5 6 7 1 88 44 17 78 32 50 48 62 2 4 1 1 2 2 3 1 54 1

Info iconThis preview shows pages 6–11. Sign up to view the full content.

View Full Document Right Arrow Icon
5 6 7 1 88 44 17 78 32 50 48 62 2 4 1 1 2 2 3 1 54 1 T 0 T 1 T 2 T 3 x y z unbalanced... ...balanced 1 2 3 4 5 6 7 T 1
Background image of page 6

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

View Full Document Right Arrow Icon
©  2004 Goodrich, Tamassia AVL Trees 7 Restructuring  (as Single Rotations) Single Rotations: T 0 T 1 T 2 T 3 c = x b = y a = z T 0 T 1 T 2 T 3 c = x b = y a = z single rotation T 3 T 2 T 1 T 0 a = x b = y c = z T 0 T 1 T 2 T 3 a = x b = y c = z single rotation
Background image of page 7
©  2004 Goodrich, Tamassia AVL Trees 8 Restructuring  (as Double Rotations) double rotations: double rotation a = z b = x c = y T 0 T 2 T 1 T 3 T 0 T 2 T 3 T 1 a = z b = x c = y double rotation c = z b = x a = y T 0 T 2 T 1 T 3 T 0 T 2 T 3 T 1 c = z b = x a = y
Background image of page 8

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

View Full Document Right Arrow Icon
©  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
Background image of page 9
©  2004 Goodrich, Tamassia AVL Trees 10 Rebalancing after a Removal Let  z  be the  first unbalanced  node encountered while travelling  up the tree from w. Also, let y be the child of z with the larger 
Background image of page 10

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

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

{[ snackBarMessage ]}