Next: 5.2 Red-Black Trees
Up: 5.1 AVL Trees
Previous: 5.1.1 Maximum Height of an AVL Tree
- While inserting a new node or deleting an existing node, the resulting
tree may violate the (stringent) AVL property. To reinstate the
AVL property, we
use rotations. See Figure 5.4.
Rotation in a BST
Figure 5.5:
Insertion in AVL trees: Scenario D
 |
Figure 5.6:
Insertion in AVL trees: Scenario C
 |
Figure 5.7:
Deletion in AVL trees: Scenario 1
 |
Figure 5.8:
Deletion in AVL trees: Scenario 2
 |
Insertion: Problem Scenario 1: (Scenario D)
-
- Scenario A is symmetrical to the above. See Figure
5.5.
Insertion: Problem Scenario 2: (Scenario C)
-
- Scenario B is symmetrical to this. See Figure 5.6.
Deletion: Problem Scenario 1:
-
- Depending on the original height of T2, the height of
the tree will be either unchanged (height of T2 = h) or gets reduced (if
height of
T2 = h - 1). See Figure 5.7.
-
- There is a scenario symmetric to this.
Deletion: Problem Scenario 2:
-
- See Figure 5.8.
As usual, there is a symmetric scenario.
Next: 5.2 Red-Black Trees
Up: 5.1 AVL Trees
Previous: 5.1.1 Maximum Height of an AVL Tree
eEL,CSA_Dept,IISc,Bangalore