AVL Deletion

This lesson will cover the deletion operation in AVL trees, discussing all the four deletion cases.

Deletion in AVL Trees

Deletion is almost similar to the insertion operation in AVLs with just one exception. The deletion operation adds an extra step after rotation and balancing the first unbalanced node in the insertion method. After fixing the first unbalanced node through rotations, start moving up and fix the next unbalanced node. Keep fixing the unbalanced nodes until you reach the root.

Algorithm for Deletion

Here is a high-level description of the algorithm for deletion.

1. Delete the given node:

Delete the given node in the same way as in BST deletion. At this point, the tree will become unbalanced and, to rebalance the tree, we would need to perform some kind of rotation (left or right). At first, we need to ...