Model Question Paper – 1 Time: 3 Hours Max marks: 100 Data

advertisement
Model Question Paper – 1
Time: 3 Hours
Max marks: 100
Data Structures and Algorithms
-------------------------------------------------------------------------------------------------PART A (5 X 2= 10 Marks)
Answer all questions
1.
The frequency count of the statement A in the following program
fragment is ------------------------.
…
for i = 1 to n do
for j = 3 to n do
y = y+i+j;
end
end
a) n+1
2.
3.
b) n.(n+1)
A
c) (n+1).(n-1)
d) n.(n-1)
For an input list that is already sorted, Quick sort reports a time
complexity of -------------------a) O(n)
b) O(n logn) c) O(n2)
d) O(log n)
(i)
(ii)
The given graph is a tree
Vertex R is a pendant vertex.
B
R
N
V
a) (i) True (ii) False b) (i) True (ii) True c) (i) False (ii) True
d) (i) False (ii) False
4.
5.
Radix sort has a time complexity of
a) O(n.(d+r)) b) O(d.(n+r))
c) O(r.(n+d))
d) O(n+d+r)
For the given linked list, the following program fragment inserts
“QUICK” as ---------------------G
L
AGILE
SHARP
FAST
GETNODE(X);
DATA(X) = “QUICK”;
G=L;
L=X;
LINK(L) = G;
a) First node of the list
c) In between FAST and SHARP
b) Last node of the list
d) In between SHARP and AGILE
PART B (10 X 3= 30 Marks)
Answer all questions
6.
7.
8.
9.
10.
11.
Compare the performance of tries with that of search trees.
Trace the Binary tree given the following inorder and post order
traversals:
Inorder traversal: O Q M S P W Postorder traversal: Q O S W P M
Test whether Selection sort is stable on the following list of elements:
34, 90, 90, 67, 90
What is a hash function? Give an example.
Construct a heap out of the given list of elements: K N A B Y C
Represent the following tree using a linked representation:
C
W
B
Y
V
12. Find the address of A[i,j] given the array A[1:10, 1:56] with the base
address as 678.
13. What are the advantages of Polyphase merge sort over balanced kway merge sort?
14. Distinguish between an AVL tree and a Binary search tree.
15. Define a B-tree of order m.
PART C ( 5 X 12 marks = 60 marks)
Answer any FIVE questions
16.
Outline algorithms to undertake (i) insertion in a linked queue (ii)
deletion in a linear stack and (iii) search for a key in an unordered
singly linked list.
17.
Outline the recursive merge sort algorithm. Draw the tree of recursive
calls to trace the sort on the following list of elements:
78 112 3 90 23
45 89
18.
Outline the algorithm for Binary search. Trace binary search for the
keys {J, P, Z} over the list { B, H, J, L, M, P, R, S, Y, Z}
19.
Explain the generic representations of LLr and RRr imbalances and
their colour changes in a Red-Black Tree. Demonstrate the working of
the appropriate representation during the insertion of the key 360 in
the following red-black tree:
350
110
480
468
550
20.
How are deletions undertaken in an m-way search tree? Construct a 4way search tree for the list { 23, 14, 67, 89, 34, 22, 88, 11, 46, 90, 18,
54, 77, 66} and demonstrate deletions of the keys 89 and 23.
21.
Outline the depth first traversal algorithm of a graph. Trace the same on
the graph whose adjacency matrix is given below, with vertex u as the
source.
u g x m
u ⎡0 1 0 1 ⎤
g ⎢⎢1 0 1 1⎥⎥
x ⎢0 1 0 1 ⎥
⎢
⎥
m ⎣1 1 1 0 ⎦
Solutions for Model Question paper 1
1.
2.
3.
4.
5.
d
c
b
b
a
Download