DBIT 305 DIT 307 DATA STRUCTURES AND ALGORITHMS.

UNIVERSITY EXAMINATIONS: 2013/2014
ORDINARY EXAMINATION FOR THE DIPLOMA IN
INFORMATION TECHNOLOGY
DBIT 305 DIT 307 DATA STRUCTURES AND ALGORITHMS
DATE: AUGUST, 2014 TIME: 1½HOURS
INSTRUCTIONS: Answer Any Three Questions.

QUESTION ONE
(a) An algorithm is defined as sequence of instructions for solving a given problem. A good
algorithm must meet a number of properties. Discuss four of those characteristics.
[4 Marks]
(b) You are required to design an algorithm that reads three different values entered by the
user through the keyboard then compares all of them and displays the smallest. Use a
pseudo code to design this program. [6 Marks]
(c) A queue is an ordered collection of data elements in which elements are added from one
end called the rear and removed from another end called front. In this regard explain the
output of the following sequence of operations.
1. s.push(10);
2. s.push(4);
3. s.push(8);
4. s.pop();
5. s.push(6);
6. s.push(5);
7. s.pop();
8. s.push(13);
[8 Marks]
(d) A heap is a binary tree which is complete and satisfies the heap order property. In this
regard, differentiate between completeness and order property of a heap. [2 Marks]
QUESTION TWO
(a) Design an algorithm to add a new node at the mid position of a linked list. [2 Marks]
(b) Discuss the following algorithms for traversing a graph:
[i]. Breadth first search [6 Marks]
[ii]. Depth first search [6 Marks]
(c) Describe the three tree traversal techniques below:
[i]. In order traversal [3 Marks]
[ii]. Post order traversal [3 Marks]
QUESTION THREE
(a) Define the following terminologies as used in tree data structures.
[i]. Root. [2 Marks]
[ii]. Edge. [2 Marks]
[iii]. Leaf. [2 Marks]
[iv]. Path. [2 Marks]
(b) Construct a hash table to store the integers 13, 2, 34, 56, 77,21,33,82 using a
suitable hash function that adequately resolves any conflict an ensures that all values
are stored in the hash table. [12 Marks]
QUESTION FOUR
(a) You are given the following elements stored in an array. Discuss how you can use
bubble sort to arrange these elements in an ascending order.
12 6 18 33 1 3 14 13 32 9
[6 Marks]
(b) Design an algorithm that locates the integer in index 6 in the array below.
Index 0 1 2 3 4 5 6 7 8
Element 12 18 9 11 32 14 13 19 7
[8 Marks]
(c) Design an algorithm that calculates and displays the factorial of an integer.
[6 Marks]
QUESTION FIVE
(a) A linked list is a linear data structure which consists of collection of nodes with
each node in the list consisting of two basic components. Describe these two
components. [4 Marks]
(b) With help of a code snippet, describe the following types of linked lists:
[i]. Singly linked list. [4 Marks]
[ii]. Doubly linked list. [4 Marks]
(c) Describe the procedure for constructing a binary search tree (BST). [8 Marks]

(Visited 109 times, 1 visits today)
Share this:

Written by