You are on page 1of 2

1

Department of Computer Science & Engineering


National Institute of Technology, Rourkela
End-Semester Examination (Spring -2012-13)
Sub: Data Structure and Algorithm (CS- 102)
Time: 3 hrs, FM: 50


Answer as many questions as possible. Mark secured above FIFTY will be converted to
FIFTY. Wherever necessary show all steps in your answer. Answer without the
intermediate steps will NOT FETCH any mark. This question paper contains TWO pages.
All questions carry equal marks.

[1] Write an algorithm to insert an ITEM into a two-way linked list sorted in increasing order. Each node
in the list contains three fields: INFO, FORW and BACKW where the pointer FORW points to the
successor and BACKW points to the predecessor of a node. Pointers HEAD points to the first node
and TAIL points to the last node in the two-way list. [5]

[2] Write an algorithm to delete an ITEM from a one-dimensional sorted array of N elements. Array is
sorted in the increasing order. Your algorithm must check for underflow condition. [5]

[3] Perform QUICKSORT on the array given below. You must show the content of the array at each step
in the sorting process. No mark will be awarded if the sorting process is not shown clearly. [5]



[4] Inorder and Postorder traversal of a binary tree is given below. Construct the corresponding binary
tree. Show each steps in the construction process. [5]
Inorder: C, D, E, B, G, H, F, K, L, P, Q, M, N, J, A
Postorder: E, D, C, H, G, Q, P, N, M, L, K, J, F, B, A

[5] Preorder traversal of an m-way search tree is defined as follows: Visit all the keys in the root node
first, followed by visiting all nodes in the subtrees beginning from left to right recursively in preorder.
Construct a 3-way search tree for the following keys: G S F L Q X Z V R A I J W. Perform preorder
traversal in the above constructed 3-way search tree as per the above definition. [2+3]
[6] Use Fibonacci search to locate the key K = 67 in the list given below. Trace each step in your search
process. [5]
11, 89, 34, 15, 90, 67, 88, 01, 36, 98, 76, 50
[7] An AVL search tree is shown in Figure -2. Delete 75 from the tree. [5]
[8] Find the shortest path from node 0 to rest of nodes in the graph using Bellman-Ford algorithm.
Adjacency matrix for the graph is shown in Figure -1. Show each step in finding the shortest path. [5]
44 33 11 55 77 90 40 60 99 22 88 66
2

[9] Find the minimum cost spanning tree for the graph, whose adjacency matrix is given in Figure -1. Use
Prims algorithm for finding the minimum cost spanning tree. [5]
[10] Construct DFS starting at node 1 for the graph whose adjacency matrix is given in Figure -1. [5]
[11] Define recursion. Write a recursive algorithm to compute the factorial of a given number N. [5]
[12] Define the following terms [1+2+2]
[a] Extended binary tree
[b] m-way search tree
[c] B tree





0 1 2 3 4 5
0 0 50 10 45
1 0 15 10
2 20 0 15
3 20 35 30
4 30 0
5
46
34 75
22 41
11
25
9
55 80
60
79
45
38
44
90
85
36 40
35
Figure -1
Figure - 2

You might also like