Вы находитесь на странице: 1из 4

NATIONAL INSTITUTE OF BUSINESS MANAGEMENT

Higher National Diploma in Computer Based Information Systems – 17.1F


Higher National Diploma in Software Engineering - 17.1F
DATA STRUCTURES AND ALGORITHMS- HNDCBIS-1-3-02

Time allowed: Three hours 27th June, 2017, 1PM-4PM

INSTRUCTIONS TO CANDIDATES

 This paper contains 7 questions on three pages


 The total marks obtainable for this examination is 100.
 All questions are given equal marks
 This examination accounts 60% for the course assessments.
 This is a closed book examination.
 All calculators are not allowed.
 Answer five questions.

ADDITIONAL MATERIALS

 None

Page 1 of 4
1. 1. Illustrate the doubly linked list with a suitable diagram
2. Why is it not practically possible to remove an element from the tail of a singly linked list. Illustrate
with an example
3. Write an algorithm to remove an element from the tail of a Doubly linked list
4. The following is an illustration of a doubly linked list, write an algorithm to remove 19 from the list

12 19 55 70

5. Write the algorithm to insert 60 into the above doubly linked list

2. 1. Illustrate the use of a recursive function using a suitable example.


2. Describe the methods available in the “Stack” Abstract Data Type(ADT)
3. Find out the output and the stack contents of the following series of stack operations
Push(1), Push(4), push(9), push(3), push(8), Pop(), Pop(), Push(1), Push(9) IsEmpty(), Pop(), Top(),
Push(10), Top(), push(2), IsEmpty(), Size(), pop(), Pop(), Pop(), Pop(), Push(5), Top(), Pop(), push(4)
Top(), Push(1), Push(17), Push(5), Size(), Pop(), Pop(), Size()
4. Find the output and the Queue contents of the following sequence of Queue operations
enqueue(6), enqueue(8), enqueue(1), dequeue(), enqueue(5), dequeue(), size(), enqueue(1),
enqueue(8), dequeue(), dequeue(), dequeue(), isEpmty(), enqueue(1), enqueue(15) enqueue(2),
front(), dequeue(), front(), enqueue(11), size(), enqueue(7), dequeue(), front() enqueue(2),
enqueue(15), dequeue(), size(), dequeue(), dequeue(), enqueue(12), size(), dequeue(),
dequeue(), isempty()

3. 1. Differentiate between Binary tree and the AVL tree


2. Illustrate with an example how to perform the following operations with an AVL tree
I. Single left rotation
II. Double rotation
3. Insert the following keys to the AVL tree, diagrammatic representation is required at each step
“34, 12, 56, 28, 94, 85, 72, 19, 27, 36, 11, 91, 68, 52, 73”
4. Insert the following key values to a (2,4) tree, diagrammatic representation is required at each step
“34, 12, 56, 28, 94, 85, 72, 19, 27, 36, 11, 91, 68, 52, 73, 99, 2, 49, 105, 4”

Page 2 of 4
4. 1. What are the 4 properties that you have to satisfy when inserting keys to a red-black tree
2. Insert the following key values to a red-black tree, diagrammatic representation is required at each
step “34, 12, 56, 28, 94, 85, 72, 19, 27, 36, 11, 91, 68, 52, 73”
3. Write a short note on algorithm analysis, your answer should include what are the different
scenarios arising in that and what scenario we can use best to analyze an algorithm. You can also
use a graph to illustrate that.
4. find the “Big O” of the following functions
I. 25X3 + 3000XlogX +1000000X
II. 59logX + X
III. X2 + 400XlogX
IV. 2X+4 + 150logX

5. The data given here refers to the following question “34, 12, 56, 28, 94, 85, 72, 19, 27”
5.1. Illustrate the divide-and-conquer method using Quick sort
5.2. Sort the above data set using the Quick sort, diagrammatic representation is required
5.3. Write the algorithm for the Merge sort
5.4. Sort the above data set using the Merge sort, diagrammatic representation is required

6. 1. Insert the following data to a binary search tree “34, 12, 56, 28, 94, 85, 72, 19, 27, 36, 11, 91, 68,
52, 73”

2. Traverse the binary search tree in the following traversing methods

I. Preorder traversal
II. In order traversal
III. Post order traversal

3. Write an algorithm to search a value to the binary search tree

4. Remove the following values from the above binary search tree

I. 19
II. 56

Page 3 of 4
7. 1. Illustrate breadth first search with a suitable diagram
2. Find the shortest path from the vertex O to all other vertices

2 10 6
A B C
O
5 7
5 6
4 14
15 P
E F
D
13 6
17 3
2 3

7 5 5 Q
G H I J
7 8
3
9 3 7
9
K T
5 5
12 11 15 R
10 17
S
2 4 V
U

3. Using Kruskal’s algorithm find the minimum spanning tree for the above diagram

Page 4 of 4

Вам также может понравиться