KIRINYAGA UNIVERSITY
END OF SEMESTER ORDINARY EXAMINATIONS
BACHELOR OF BUSINESS INFORMATION TECHNOLOGY YEAR 2, SEMESTER
2/ BACHELOR OF SCIENCE IN COMPUTER SYSTEMS ENGINEERING YEAR 1
SEMESTER 2
SPC 2106 Data Structures And Algorithms TIME: 2 HOURS
Instructions
Attempt question ONE and ANY OTHER TWO Questions
Question One (30 Marks)
a) Explain the three properties of an array. (3 Marks)
b) Write an algorithm to add a node in a queue. (4 Marks)
c) Outline any two factors to consider when determining the efficiency of an
algorithm. (2 Marks)
d) Distinguish between a root node and a terminal node as used in a binary tree.
(4 Marks)
e) Using a diagram, distinguish between a singly linked list and doubly linked list.
(4 Marks)
f) Explain the operation of the following linear data structures.
i. Stack
ii. Queue (6 Marks)
g) Write an algorithm for the in-order tree traversal (3 Marks)
h) Calculate the adjacency matrix of the graph below. (4 Marks)
Page 1 of 3
Question Two
a) Use the bubble sort algorithm to sort the data elements: 43, 32,7, 12, 98. Show all
your working and indicate the number of passes. (5 Marks)
b) Distinguish between first-depth and breath-first search. (4 Marks)
c) Using a diagram distinguish between in-degree and out-degree of a graph.
(5 Marks)
d) Write a code snippet in C Language for an algorithm to delete a node from a
stack. (6 Marks)
Question Three
a) Using C language, write a code snippet for the binary search algorithm.
(7 Marks)
b) Explain any three operations that can be performed on data structures.
(6 Marks)
c) With an aid of a diagram, explain the operation of a queue. (5 Marks)
d) Outline any two application areas of a graph in computing.
(2 Marks)
Question Four
a) Using a diagram, distinguish between directed graph and double ended non-
directed graph. (4 Marks)
b) Using selection sort, demonstrate how the following elements: 10,56,5,29,78 can
be sorted. Show all your working. (5 Marks)
c) Explain any four criteria that must be satisfied by an algorithm. (8 Marks)
Page 2 of 3
d) With an aid of a diagram, describe a Red-Black tree (3 Marks)
Question Five
a) Write a code to create a node of a double linked list. (4 Marks)
b) Explain any two application areas of queues in computing. (4 Marks)
c) Write a C language code to create a 2-dimenssion array (2*4) called “scores” of
type integer. The array should be initialized with the following values:
76,89,54,97,63,71,82,78. (4 Marks)
d) Using C language, write a code snippet for the linear search algorithm. (8 Marks)
Page 3 of 3