Title: AVL Search Tree
1AVL Search Tree
2put(9)
-1
10
0
1
1
7
40
-1
0
1
-1
0
45
8
3
30
0
-1
0
0
0
0
60
35
9
1
20
5
0
25
3put(29)
-1
10
1
1
7
40
-1
0
1
0
45
8
3
30
0
0
-1
0
0
-2
60
35
1
20
5
0
-1
RR imbalance gt new node is in right subtree of
right subtree of blue node (node with bf -2)
25
0
29
4put(29)
-1
10
1
1
7
40
-1
0
1
0
45
8
3
30
0
0
0
0
0
60
35
1
25
5
0
0
20
29
RR rotation.
5AVL Rotations
6Put(1)
-1
10
2
1
0
7
40
1
0
0
0
50
3
30
0
0
45
60
0
0
35
20
20
1
LL imbalance gt new node is in left subtree of
left subtree of blue node (node with bf 2)
7Put(1)
Put(1)
-1
10
0
0
40
3
0
0
0
0
50
1
30
7
0
0
45
60
0
0
35
20
20
LL rotation
8 Put(8)
2
1
-1
10
0
3
40
2
4
8
LR imbalance gt new node is in right subtree of
left subtree of blue node (node with bf 2)
9 Put(8)
2
1
-1
10
0
3
40
LL ROTATION
2
4
8
RR ROTATION
LR rotation is an RR rotation followed by LL
rotation
10 Put(8)
2
1
-1
10
0
4
40
LL ROTATION
3
8
2
RR ROTATION (after first rotation)
LR rotation is an RR rotation followed by LL
rotation
11 Put(8)
4
10
3
8
40
2
RR ROTATION (after second rotation)
12Put(5)
-2
-1
2
1
0
8
1
9
7
5
RL imbalance gt new node is in left subtree of
right subtree of blue node (node with bf -2)
13Put(5)
-2
-1
2
1
0
8
1
RR ROTATION
9
7
5
LL ROTATION
RL rotation is an LL rotation followed by an RR
rotation
14Put(5)
-2
-1
2
1
0
7
1
RR ROTATION
8
5
9
AFTER FIRST ROTATION
RL rotation is an LL rotation followed by an RR
rotation
15Put(5)
7
2
8
9
5
1
AFTER SECOND ROTATION
16delete(45)
2
1
10
0
0
-1
6
40
0
0
0
45
8
3
0
0
0
0
1
7
5
9
17delete(45)
-1
6
0
1
3
10
0
0
0
0
5
1
40
8
0
0
7
9
18delete(45)
2
1
10
0
1
-1
6
40
0
0
0
45
8
3
0
0
1
5
19delete(45)
0
6
0
0
3
10
0
0
0
0
5
1
40
8
20delete(45)
2
1
10
0
-1
-1
6
40
0
0
0
45
8
3
0
0
7
9
21delete(45)
0
8
0
0
6
10
0
0
0
0
7
3
9
40
After R-1 rotation