Professional Documents
Culture Documents
Single Left Rotation PDF
Single Left Rotation PDF
The case of single right rotation occur when Insertion of a node takes place
into right sub-tree of right child of any node (lets say node X)
So After the Insert, move toward the root, node by node checking balance
factor at each, because only nodes on the path from insertion point toward
root node have possibly changed in height and have violated balanced
property .
Let the node that needs rebalancing be node X.
BF = -1- (1) = 2
X
Y
Y
Left Rotation
Z
Insert number 4 5 6 7 8 into an empty AVL Tree.
Example
BF = -1 - (1) = -2
4
Insert 4
Insert 5
Insert 6
5
Left Rotation
5
6
Insert 7
5
BF = 2
Left Rotation
7
6
Insert 8
6
7
6
7
Unbalanced Tree
B
A
X
Left Rotation
Example:-
3
BF = 0 - 2 = - 2
Left Rotation
7
6
1
8
5
4
8
6
X
Q
Y
Left Rotation
Null
Null
B
Q
X
X
A
C
Left Rotation
Y
Z
Y
C
Example:-
20
20
30
10
10
30
Insert 50
BF = -1-(1) = - 2
35
25
35
25
40
40
Left Rotation
50
20
20
BF = 0 - 2 = -2
30
10
10
30
Insert 60
5
25
40
35
25
50
40
35
50
60
Left Rotation
20
20
20
BF = 2 - 0 = 2
40
10
30
25
50
35
40
10
Insert 2
60
30
25
Right Rotation
50
35
60
40
10
50
30
25
35
60