Documente Academic
Documente Profesional
Documente Cultură
unchen
Fakultat f
ur Informatik
Lehrstuhl f
ur Effiziente Algorithmen
Prof. Dr. Harald Racke
Chintan Shah
Wintersemester 2012
Losungsblatt 4
22 November 2012
15
26
12
21
35
14
29
38
1. Insert 10
2. Delete 29
3. Delete 21
4. Delete 3
L
osungsvorschlag
1. Insert 10
Standard Insert
15
26
12
10
21
14
35
29
38
2. Delete 29
Standard Delete
15
26
12
21
10
35
14
38
3. Delete 21
Case 4 (for dummy right child of 21)
15
35
12
10
26
38
14
4. Delete 3
z(5) is red
15
35
12
10
26
14
38
33
20
42
12
27
15
25
37
48
29
1. Insert 5
2. Delete 27
3. Insert 27
L
osungsvorschlag
1. Insert 5
33
20
42
12
27
15
37
25
29
48
Case-1 (z:5)
33
20
42
12
27
15
37
25
48
29
5
Case-2b (z:12)
20
12
33
15
27
25
42
29
37
48
2. Delete 27
Standard Delete
20
12
33
15
29
25
42
37
48
3. Insert 27
20
12
33
15
29
42
25
37
48
27
Case-2a (z:27)
20
12
33
15
29
42
27
37
48
25
Case-2b (z:25)
20
12
33
15
27
25
42
29
37
48
21
10
30
14
26
37
28
39
Carry out the following operations sequentially on the tree so that it remains an AVL tree
and show what the tree looks like after each operation(always carry out each operation
on the result of the previous operation):
1. Insert 16
2. Delete 30
3. Insert 22
4. Insert 27
Lo
sungsvorschlag
Yes, the given binary tree is an AVL tree.
1. Insert 16
Case-1 (v:10)
21
14
10
30
16
26
37
28
39
2. Delete 30
21
14
37
10
16
26
39
28
3. Insert 22
21
14
37
10
16
26
39
22
28
4. Insert 27
DoubleRightRotate(37)
21
14
10
28
16
26
22
37
27
39