AVL Tree Animation

download AVL Tree Animation

of 20

description

avl

Transcript of AVL Tree Animation

  • AVL Tree Example: Insert 14, 17, 11, 7, 53, 4, 13 into an empty AVL tree1417117534

  • AVL Tree Example: Insert 14, 17, 11, 7, 53, 4, 13 into an empty AVL tree141774531113

  • AVL Tree Example: Now insert 1214177453111312

  • AVL Tree Example: Now insert 1214177453111213

  • AVL Tree Example: Now the AVL tree is balanced.14177453121311

  • AVL Tree Example: Now insert 8141774531213118

  • AVL Tree Example: Now insert 8141774531112813

  • AVL Tree Example: Now the AVL tree is balanced.141774531112813

  • AVL Tree Example: Now remove 53141774531112813

  • AVL Tree Example: Now remove 53, unbalanced1417741112813

  • AVL Tree Example: Balanced! Remove 111417741112813

  • AVL Tree Example: Remove 11, replace it with the largest in its left branch14177481213

  • AVL Tree Example: Remove 8, unbalanced1417471213

  • AVL Tree Example: Remove 8, unbalanced1417471213

  • AVL Tree Example: Balanced!!1417471213

  • In Class ExercisesBuild an AVL tree with the following values:15, 20, 24, 10, 13, 7, 30, 36, 25

  • 1515, 20, 24, 10, 13, 7, 30, 36, 252024152024101315202413101320241510

  • 132024151015, 20, 24, 10, 13, 7, 30, 36, 257132024151073036132030151073624

  • 13203015107362415, 20, 24, 10, 13, 7, 30, 36, 25251320301510736242513243620107253015

  • Remove 24 and 20 from the AVL tree.1324362010725301513203615107253013153610725301330361072515