Professional Documents
Culture Documents
Deletion of nodes from an AVL tree is similar to that of Insertion. But the
main difference between AVL Insertion and AVL Deletion is that:
AVL Tree deletion = Binary Search Tree delete (Search the node, and remove it)
Attention
Dont confuse if you found different case of AVL tree deletion (such as R0,
R1, R-1, L0, L1, and L-1). All these six cases get automatically covered in
above three case of AVL Tree deletion.
Case 1
BF =0- (2) = - 2
25
25
30
22
Delete 23
30
22
Left Rotation at
node 25
30
40
25
40
28
40
28
23
22
35
35
50
28
35
50
50
Delete 28
BF =-1 - (1) = - 2
30
30
30
Delete 25
25
40
35
50
Left Rotation at
node 30
40
30
35
Delete 22
50
25
40
35
50
22
40
35
50
30
30
BF =1 - (-1) = 2
25
25
40
40
Delete 26
22
35
26
34
20
22
50
45
34
20
60
50
35
45
60
70
70
Right Rotation
at node 25
BF =1 - (3) = - 2
40
30
30
35
22
20
50
25
34
45
Left Rotation at
node 30
60
22
20
70
40
50
35
25
34
45
60
70
Case 2
BF =0 - (2) = - 2
22
20
30
20
Left Rotation at
node 25
30
Delete 22
28
27
30
25
25
40
28
40
27
35
40
25
20
35
28
35
27
Delete 40
30
28
30
25
20
Left-Right Rotation
at node 30
27
35
35
25
20
28
27
Case 3
45
45
BF = 1-(-1) =2
68
28
20
15
30
80
50
35
25
28
Delete 68
30
20
15
55
80
50
35
25
55
18
18
Left-Right Rotation
at Node 80
45
28
15
25
18
Right Rotation
at node 45
45
20
20
0
30
30
35
28
28
30
15
50
30
25
18
55
35
80
Example
Let us take an example of deletion which covers all the three cases as discussed
above.
65
65
50
40
Delete 40
70
68
60
55
50
68
67
55
75
Right-Left Rotation
at node 50
70
60
80
67
65
80
55
50
70
60
75
68
67
80
75
Delete 60
65
65
70
70
50
65
80
Left Rotation
at node 65
68
50
68
75
67
55
Delete 55
50
80
67
Delete 70
68
75
65
80
68
50
40
65
50
68
67
75
Left-Right Rotation
at node 75
70
75
40
80
80
75