blob: f60b1ec2fd52e3a83f4ba9b8258482dc04bcd695 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
Illustrate that via AVL single rotation, any binary search tree T1 can be
transformed into another search tree T2 (with the same items).
Left rotation:
```plaintext
(10) (20)
\ / \
(20) -> (10) (30)
\
(30)
```
Right rotation:
```plaintext
(30) (20)
/ / \
(20) --> (10) (30)
/
(10)
```
Left-Right rotation:
```plaintext
(30) (20)
/ / \
(10) -> (10) (30)
\
(20)
```
Right-Left rotation:
```plaintext
(10) (20)
\ / \
(30) --> (10) (30)
/
(20)
```
Give an algorithm to perform this transformation using O(N log N) rotation on average.
See `./../avl_tree.c`.
|