Document
Document
Registration no:
Max Marks: 70
Q.CODE: W480
Answer Question No.1 which is compulsory and any five from the rest.
The figures in the right hand margin indicate marks.
g) How does kruskal’s algorithm know when the addition of an edge will
generate a cycle?
h) What is the basic objective of Rabin-Karp Pattern matching algorithm?
i) Consider two sets set-1={b, c, e, h} and set-2={f, g, d}. c and f are the
representative of set-1 and set-2 respectively. Show the linked list
representation of both sets and also show the union operation of both list
obtained.
109 109 109 109 109 109 109 109
j) What do you mean by approximation algorithm and approximation ratio?
Q3 a) Write an algorithm to construct a min heap. Construct max heap from the (5)
following list: {16,14,10,8,7,9,3,2,4,1}
b) Write down the algorithm of binary search. Show that the worst case time (5)
complexity of binary search is O(lg n)
Q4 Write down the algorithms for MERGE-SORT and MERGE procedure. Prove (10)
109 109
that the running
109
time of merge
109
sort is ϴ(n lg109n) . 109 109 109
1Page
Q5 a) Write down the algorithms for BFS and DFS. Specify the running time of both (5)
109 109 109 109 109 109 109 109
algorithms.
b) Define LCS. Write down the algorithm for computing the length of an LCS. (5)
Find the LCS from the given sequences X={A,B,C,B,D,A,B} and
Y={B,D,C,A,B,A}
algorithm. Draw the Hoffman tree for the given node values: f:5 , e:9, c:12,
b:13, d:16, a:45
Q7 a) Write down Kruskal’s and Prim’s algorithms and also specify the running time (5)
of both algorithms.
b) Write down Bellman-Ford and Dijkstra’s algorithms and also specify the (5)
running time of both algorithms.
109 109 109 109 109 109 109 109