0% found this document useful (0 votes)
28 views3 pages

Cosc 325

Uploaded by

yvonnengugi9703
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views3 pages

Cosc 325

Uploaded by

yvonnengugi9703
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

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

DAY/DATE: WEDNESDAY 15/4/2020 8.30 AM – 10.30 PM


INSTRUCTIONS:

• Answer question ONE and TWO other questions


• Do not write anything on the question paper
• This is a closed book exam, no reference materials are allowed in the examination room
• There will be NO use of mobile phones or any other unauthorized materials
• Write your answers legibly and use your time wisely.

SECTION A (ANSWER ALL QUESTIONS)

QUESTION ONE (30 MARKS)

a) Define the following terms.


(i) Data (1mk)
(ii) Data type (1mk)
(iii) Data structure (1mk)
(iv) Abstract data structure (1mk)
(v) Algorithm (1mk)

b) Explain in detail what you understand by the term “Analysis of an algorithm”. What
issues are of concern? (5mrks)

c) Given the array below answer the questions that follow

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)

Question 2 (20 mrks)

(a) Briefly describe the Queue data structure. (1mrk)

(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();

(c) Describe the linked list implementation of a Queue. (5mks).

(d) Describe the array implementation of a queue. (5mks)

(e) Compare the Array and linked list implementation of a Queue in terms of (5mks)
(i) Insertion
(ii) Deletion
(iii) Search

Question 3 (20 mrks)

(a) Briefly describe the Stack data structure. (1mk)

(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();

(c) Describe the linked list implementation of a Stack. (5mks)

Page 2 of 3
COSC 325

(d) Describe the array implementation of a Stack. (5mks)

(e) Compare the Array and linked list implementation of a Stack in terms of: (5mks)

(i) Insertion
(ii) Deletion
(iii) Search

Question 4 (20 mrks)

(a) Briefly describe the Binary Tree data structure. (2mks)

(b) Draw the binary search tree (BST) you get by inserting the following sequence into an
initially empty tree (8mks)

13, 3, 4, 12, 14, 10, 5, 1, 8, 2, 7, 9, 11, 6, 18


(c) Briefly discuss two pre conditions for each of the following data structures (4mks)
i. Stack
ii. Queue

(d) Briefly discuss the following notations and give example in each case. (6mks)
i) Prefix.
ii) Infix.
iii) Postfix.

Question 5 (20 mrks)

(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

You might also like