Cosc 325
Cosc 325
THARAKA UNIVERSITY
COLLEGE
UNIVERSITY EXAMINATIONS
EXAMINATION FOR THE AWARD OF BACHELOR OF SCIENCE IN
COMPUTER SCIENCE
COSC 325: DATA STRUCTURES AND ALGORITHMS
STREAMS: BSC COMP SCI Y3S1 TIME: 2 HOURS
b) Explain in detail what you understand by the term “Analysis of an algorithm”. What
issues are of concern? (5mrks)
17 23 5 11 2 29 3
i) Briefly explain any two limitation of array as a building block of other data
structures. (4mks)
(ii) Diagrammatically represent how selection sort would be performed on the array data
items. (10mrks)
Page 1 of 3
COSC 325
(iii) Give the advantages and disadvantages of both selection and bubble sort
algorithms. (6mrks)
(b) Draw the symbolic representation of the Queue data structure after implementation of the
following sequence of member function calls. (4mrks)
S.addQ(5);
S.addQ(17);
S.addQ(35);
S.removeQ();
S.addQ(53);
S.addQ(34);
S.removeQ();
S.removeQ();
(e) Compare the Array and linked list implementation of a Queue in terms of (5mks)
(i) Insertion
(ii) Deletion
(iii) Search
(b) Draw the symbolic representation of the stack data structure after implementation of the
following sequence of member function calls. (4mks)
S.push(5);
S.push(17);
S.push(35);
S.pop();
S.push(53);
S.push(35);
S.pop();
S.pop();
Page 2 of 3
COSC 325
(e) Compare the Array and linked list implementation of a Stack in terms of: (5mks)
(i) Insertion
(ii) Deletion
(iii) Search
(b) Draw the binary search tree (BST) you get by inserting the following sequence into an
initially empty tree (8mks)
(d) Briefly discuss the following notations and give example in each case. (6mks)
i) Prefix.
ii) Infix.
iii) Postfix.
(a) Explain two direct application areas of each of the following data structures (8mks)
(i) Stack
(ii) Queue
(iii) Linked list
(iv) Tree
(b) For a tree data structure and using a suitable diagram, briefly explain the following
concepts. (12mks)
(i) Degree
(ii) Level or depth of a node
(iii) Descendant
(iv) Leaf
(v) Child
(vi) Grandchild
------------------------------------------------------------------------------------------------------------
Page 3 of 3