Professional Documents
Culture Documents
Acsse Csc03a3 2020 2-4
Acsse Csc03a3 2020 2-4
MODULE CSC03A3/CSC3A10
COMPUTER SCIENCE 3A
QUESTION 1
Consider the following (2,4) tree provided below. Draw the (2,4) tree state
after each of the following operations. If the tree is rebalanced draw the
state before and after it being balanced.
31
6 28 39 40
Solution:
Insert 18
[1 mark]:
31
6 18 28 39 40
Insert 13
<<Rebalancing>> [2 marks]:
18 31
6 13 28 39 40
[1 mark]:
18 31
6 13 28 39 40
Insert 41
[1 mark]:
Page 1 of 6
Computer Science 3A (2,4) Tree Examples 2020-05-20
18 31
6 13 28 39 40 41
Insert 1
[1 mark]:
18 31
1 6 13 28 39 40 41
Insert 17
<<Rebalancing>> [2 marks]:
13 18 31
16 17 28 39 40 41
[1 mark]:
13 18 31
16 17 28 39 40 41
Insert 22
[1 mark]:
13 18 31
16 17 22 28 39 40 41
Insert 41
Remove 6
[1 mark]:
13 18 31
1 17 22 28 39 40 41
Remove 1
13 [1 mark]:
Page 2 of 6
Computer Science 3A (2,4) Tree Examples 2020-05-20
18 31
13 17 22 28 39 40 41
Remove 31
[1 mark]:
18 28
13 17 22 39 40 41
Remove 17
[1 mark]:
18 28
13 22 39 40 41
Remove 22
[1 mark]:
18 39
13 28 40 41
Total: 15 marks
Total: 15
QUESTION 2
Consider the following (2,4) tree provided below. Draw the (2,4) tree state
after each of the following operations. If the tree is rebalanced draw the
state before and after it being balanced.
Page 3 of 6
Computer Science 3A (2,4) Tree Examples 2020-05-20
18
05 29 48
Solution:
Insert 35
[1 mark]:
18
05 29 35 48
Insert 29
Insert 2
[1 mark]:
18
025 29 35 48
Insert 34
<<Rebalancing>> [2 marks]:
18 35
025 29 34 48
[1 mark]:
18 35
025 29 34 48
Insert 8
<<Rebalancing>> [2 marks]:
5 18 35
02 8 29 34 48
[1 mark]:
Page 4 of 6
Computer Science 3A (2,4) Tree Examples 2020-05-20
5 18 35
02 8 29 34 48
Insert 19
[1 mark]:
5 18 35
02 8 19 29 34 48
Insert 49
[1 mark]:
5 18 35
02 8 19 29 34 48 49
Remove 5
[1 mark]:
2 18 35
0 8 19 29 34 48 49
Remove 34
[1 mark]:
2 18 35
0 8 19 29 48 49
Remove 49
[1 mark]:
2 18 35
0 8 19 29 48
Remove 35
[1 mark]:
Page 5 of 6
Computer Science 3A (2,4) Tree Examples 2020-05-20
2 18 29
0 8 19 48
Remove 29
[1 mark]:
2 18
0 8 19 48
Total: 15 marks
Total: 15
— End of paper —
Page 6 of 6