Design Algorithm 2009
Design Algorithm 2009
Q.1 (a) Differentiate between quick sort and mergesort algorithms. (2)
(b) Find the maximum and minimum element in an array with minimum
complexity. (3)
(c) Differentiate between Divide and Conquer and Dynamic programming. (2)
(d) Give algorithm for native string matching. (2)
n
(e) Find complexity of ∑i3 . (2)
i=1
B E
A
C F H
(h) Find spanning tree for the following figure:- (2)
4 6
1 2 3
1 3 5
4 5
4 5 6
9 7 2
5 3
7 8 9
1 2 2 1
*
3 4 1 2
UNIT-I
Q.2 (a) Solve T(n) = 2T(n/4) + √n for T(1) = 1. (4)
(b) Show how to multiply the complex numbers (a+bi) and (c+di) using only
three real multiplications. (6)
Q.3 (a) Solve T(n) = T(n/2) + T(n/4) + T(n/8) + n for T(1) =1. (5)
(b) Give algorithm with complexity for selection in expected linear time. (5)
UNIT-II
Q.4 (a) Explain Matrix Chain Multiplication using dynamic programming. (5)
(b) Find the Huffman code for (5)
Variables A B C D E F G H
Frequencies 0.25 0.25 0.14 0.14 0.055 0.055 0.055 0.055
UNIT-III
Q.6 (a) Find the shortest path from S to F for the following figure: (5)
A 4 -3 D
3
C 1
S -2 2
5
2 B E
-2
3
F
(b) Give Breath first traversal algorithm along with its complexity. (5)
Q.7 (a) Apply Floyd Warshall algorithm for constructing shortest path for the
Following figure, showing the matrix. (5)
1 1 2
2
-1
-4 7
3 3 4
(b) Give Dijkastra algorithm along with its complexity. (5)
UNIT-IV
Q.8 (a) Construct the string matching automation for the pattern P=ababcab and
Illustrate its operation on the text string T=aaabababcababccab. (5)
(b) Prove that vertex cover problem is NP-complete. (5)
Q.9 (a) Compute the prefix function (KMP method) for the pattern
ababbabbabbabababbabb when the alphabet is ∑={a,b}. (5)
(b) Prove that 3-satisfiability is NP-complete. (5)
***********