Comp 214 Main Exam
Comp 214 Main Exam
UNIVERSITY EXAMINATIONS
MAIN CAMPUS
THIRD SEMESTER, 2022 ACADEMIC YEAR
EXAMINATION FOR THE DEGREE OF BACHELOR OF SCIENCE
COMPUTER SCIENCE/ INFORMATION TECHNOLOGY
INSTRUCTIONS
1. Answer Question 1 and any other two questions in the answer booklet provided.
2. Do not write on your question papers. All rough work should be done in your answer
booklet.
3. Clearly indicate which question you are answering.
4. Follow all the instructions in the answer booklet
5. Write neatly and legibly
As members of Kabarak University family, we purpose at all times and in all places, to set apart in one’s heart, Jesus
as Lord. (1 Peter 3:15)
Kabarak University is ISO 9001:2015 Certified
Page 1 of 5
SECTION A: (COMPULSORY) TOTAL MARKS FOR THIS SECTION IS 30.
1.
(a) Compare arrays and linked list data structures based on the following properties
(i) Cost of accessing and element [2 Marks]
(ii) Memory requirement [2 Marks]
(iii) Memory utilization [2 Marks]
(d) Use division method and open addressing to store the following values: 3, 2, 9, ,11,13, 7,12
into a hash table of length 10 and hash function h(k) = k mod 10 . Show your working and
the resultant hash table [8 Marks]
(e) Specify the total number of probes used to store the values in the hash table in question (d)
[2 Marks]
(f) Discuss any TWO applications of a tree data structure [4 Marks]
As members of Kabarak University family, we purpose at all times and in all places, to set apart in one’s heart, Jesus
as Lord. (1 Peter 3:15)
Kabarak University is ISO 9001:2015 Certified
Page 2 of 5
SECTION B. TOTAL MARKS FOR THIS SECTION IS 40.
ANSWER ANY TWO QUESTIONS FROM THIS SECTION. EACH QUESTION IN THIS
SECTION CARRIES 20 MARKS.
2.
(a) The following items are to be inserted into an empty linked list in the order in which they
appear: 3, 7 , 100. Assuming that the items have been assigned memory addresses: 100, 250,
and 800 respectively.
(i) Draw a diagrammatic representation of this procedure in a double linked list
[4 Marks]
(ii) Write an implementation code for the procedure (a) in C Language [4 Marks]
(b) Consider the following tree
(i) List all the parent and child node of the following tree [2 Marks]
(ii) Determine the degree and level of the above tree [2 Marks]
(iii) Does this tree qualify to be a binary tree? [1 Mark]
(iv) Explain your answer [2 Marks]
As members of Kabarak University family, we purpose at all times and in all places, to set apart in one’s heart, Jesus
as Lord. (1 Peter 3:15)
Kabarak University is ISO 9001:2015 Certified
Page 3 of 5
(c) Use Kruskal’s algorithm to find the minimum spanning tree for this network. Draw the tree
and give its total weight [5 Marks]
3.
(a) Use the following expression: A-(C/5*2) + (D*5%4) to construct a binary expression tree.
Show your working [6 Marks]
(b) Write the pre-order and post-order traversal of the tree constructed in (a) above [4 Marks]
(c) Write a C program to dynamically initialize a single dimensional array of size n where n=5
with integer values then
(i) Display the elements of the array and their respective locations in the array
[5 Marks]
(ii) Insert item 250 at location 3 of the array and display the elements of the array
after the operation had been completed. [5 Marks]
4.
(a) State one major drawback of an ordinary queue [1 Mark]
(b) Explain how the function enqueue and dequeue operation can be modified to to resolve this
drawback stated in (a) above [2 Marks]
(c) Write the algorithms for enqueue and dequeue operations in a circular queue
[9 Marks]
(d) Insert the following keys into a B-tree of 5-way order:1 12 8 2 25 5 14 28 17 7 52 16 48 68
3 26 29 53 55 45 [8 Marks]
As members of Kabarak University family, we purpose at all times and in all places, to set apart in one’s heart, Jesus
as Lord. (1 Peter 3:15)
Kabarak University is ISO 9001:2015 Certified
Page 4 of 5
5.
(a) Describe the TWO major operations in a stack [6 Marks]
(b) Write a C program to display the Name: River in reverse order using a stack data structure
[8 Marks]
(c) Explain THREE applications of stacks [6 Marks]
As members of Kabarak University family, we purpose at all times and in all places, to set apart in one’s heart, Jesus
as Lord. (1 Peter 3:15)
Kabarak University is ISO 9001:2015 Certified
Page 5 of 5