You are on page 1of 3

BIT 2202 DATA STRUCTURES AND ALGORITHMS PAPER 2

Data structures and algorithms paper 2


Q1
a) Define the following terms; [6 marks]
i. Data structure
ii. Balanced binary tree
i. Graph-Heap

b) If you are requested to write an application to simulate the inbox of your mobile phone in
reference to arrival of new massages

i) Suggest the appropriate data structure you will use and justify answer [2 marks]
ii) What are the factors that will guide you to choose the particular data structure in
(i) above [2 marks]

iii) Write pseudo code to accept new massages [5 marks]


iv) How to you test if the inbox is empty or full [3 marks]

c) Cite any three areas where queues can be applied in information systems
[3 marks]
d) Define data encapsulation and give any two advantages [3 marks]
g) Define space complexity. Why is it important in analysis of algorithms [3 marks]
h) Tree data structures are special graphs discuss [3 marks]

Q2
a) Define a list ADT [2 marks]
b) Draw a flow chart to [5 marks]
i) Add a new item X at position i
ii) Deletes item at position i

c) i) Discuss the any two heap operations [4 marks]


ii) Represent the array below in a binary tree. Perform a heap sort on it [5 marks]

[0] 19
[1] 60
[2] 23
[3] 66
[4] 30 d) Trace the steps of binary search for the key field 20 in the array
[5] 8 below
[6] 10
[4 marks]

70 63 52 8 10 12 60 56 32 30 14
[1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11]
Q3
a) i) Define a stack ADT [2 marks]
ii) Define the sequential search [2 marks]
b) Show how the following items; 40 50 30 can be implemented in stack ADT as an
array [2 marks]

c) Trace the behavior of the following operation on (b) above PUSH (70) PUSH (80)
PUSH(90) POP() PUSH(77) POP() [3 marks]
d) Give all order of traversal for following binary tree [6 marks]

B C

D E F G

H I J

e) Write a pseudo code for a binary search tree. Assume the array is already sorted
[5 marks]

Q4
a) Given the equation (A+B)*C/F construct a binary tree and come up wit prefix,
infix and post fix notation [6 marks]
b) What are the major data structures used in the following areas : RDBMS,
Network data model & Hierarchical data model. [6 marks]
c) Define a binary search tree and its properties [6 marks]

d) The cost of sequential search id On and that of the binary search id Olog2n
Which faster between the two. Justify your answer [2 marks]

Q5
a) What are the advantages of linked lists? [4 marks]
b) Explain any three desirable traits of a good algorithm [3marks]
c) Suppose you delete items from an array based on implementation of list but do not
close the gaps. State any two problems that may arise [4 marks]
d) Given the tree below perform a down-heap followed by up-heap of value 10 and 3

[6 marks]

6 5

9
8
e) Explain the applications of stack? [3 marks]

You might also like