CSC508 TEST2 16jan2023
CSC508 TEST2 16jan2023
CSC508 TEST2 16jan2023
CONFIDENTIAL CS/JAN2023/CSC508/TEST 2
INSTRUCTIONS TO CANDIDATES
QUESTION 1 14
QUESTION 2 20
QUESTION 3 20
QUESTION 4 16
TOTAL SCORE 70
How many comparisons are required to find whether items 73 and 99 are in the list?
a) Using Sequential Search algorithm? (5 marks)
b) Using Binary Search algorithm? (5 marks)
c) Hashing.
Let H be a closed hash table of size 12 (indices 0 to 11) in which the following set of
keys are currently stored: {32, 765, 81, 900, 74, 70, 86, 345, 48, 79}.
Show the content of Hash Table if the following algorithm is used:
i) Linear Probing (5 marks)
ii) Chaining (5 marks)
50
0
30 80
40 55
25
48
i. Insert values 70 AND 45 into the AVL Tree above. Show the work done after
each insertion. The resulting tree must also be an AVL tree.
(8 marks)
ii. What are the balance factors at each node after the insertion in (i).
(2 marks)
E F
A
C
G
B
CS/JAN2023/CSC508/TEST 2
c) Based on the graph in (b), if all the edges have weights associated to it, find the
shortest path from vertex A to any other vertices in the graph using Djikstra algorithm.
3 E F
1 7
A
C 2 1
3 D 9
8
G
B
5
(7 marks)