Analysis and Design of Algorithm Paper 2
Analysis and Design of Algorithm Paper 2
Analysis and Design of Algorithm Paper 2
USN
Four~b Semester B.E. Degree Examination, December 2010
06CS43
Analysis
Time: 3 hrs.
and Design
of Algorithms
Max. Marks: 100
Note: Answer any FIVEfull questions, selecting at least TWO questions from each part PART-A
I..i
~
-0
<'.> 1;j
a. What is an algorithm? With a neat diagram, explain the algorithm design and analysis process. (10Marks) b. Define the asymptotic notations for worst case, best case and average case time complexities. Give example. (10Marks)
a. With a suitable example, explain the significance of the order of growth in analyzing the algorithm efficiency. (10 Marks)
~
,,; <'.>.0 <'.>
~=
Q.....><:
~
0
-11"\
",0
II
.0
.';;j
b. Provethat: . i) n(n -1) E 8(n2) ii) n! E Q (2n). (04Marks) c. Distinguishbetweenthe two commonwaysto representa graph - given the representation
of undirected graph. Explain how the following can be ascertained by the representation i) The graph is completed' ii) The graph has a loop iii) The graph has an isolated vertex Answer for each of the representation separately. (06Marks)
3'
gfoo
eN
"'"
E ~
eili
1)
e
'"
e .;:: 0
~
e
0
a. What is a "Bruteforce" method? Under what condition does the method become desirable?
b. c. State the merge sort algorithm and analyze its complexity. Outline an exhaustive search algorithm to solve the traveling salesman problem. (06 Marks) (08 Marks) (06 Marks)
'"
Q)
.S
e--
~]
....
-0
~ 1;j
'" ... ::I -0 '"
'.
a. Briefly explain the strassen's matrix multiplication. Hovvit uses divide and conquer method? Obtain its time complexity. (06Marks) b. Write an algorithm to topologically sort a diagrph using DFS. Prove the correctness of the algorithm, with examples. (08Marks) c. With the suitable example, explain the Johnson trotter algorithm, to generate the permutation of given objects. (06Marks)
E 0 () 0
PART-B
5
'
~~
a. What is an AVL tree? Explain the four types of rotations used to construct the AVL tree. Insert 1,25,28, and 12 in the following tree. -4-L
10
- '" Q..Q)
() >.
E ;> 0 ~
e e 0 <X: "':N
Q) .... 0
Fig. Q5(a)
(10 Marks)
Z ~
t: 0 Q.. .
b. When does collision occur in hashing? Arrange the following keys in the hash table of size 10, using open hashing technique. A, GOOD, STUDENT, WORKS, HARD. (04Marks) c. Construct a Huffman code for the following data: Char A B C D E
0.1 0.25 0.2 Probability 0.4 i) Encode the text A B A CAB A D using generated code ii) Decode the text whose encoding is 10001011100101. 10f2 0.15
(06 Marks)
, .,;-
~-
06CS43
a. With the help of pseudocode, explain Marshall's algorithm to find the transitive closure of a directed graph. Apply it to the graph shown below: (10Marks)
Fig. Q6(a) b. Find the minimum spanning tree, using Prim's method for the graph shown below:
(10 Marks) 7
a. Find the single source shortest paths. Apply the Dijkstra's algorithm to Fig. Q7(a),to get the shortest path form the vertex to all the other vertices.
b.
Fig. Q7(a) (10 Marks) Write a bottom-up dynamic algorithm for the knapsack problem. Apply it on the following instance of the knapsack problem. (10 Marks)
Item 1 2 3 4
Weight 2 3 4 5
Table Q7(b)
Value 3 4 5 6
'\
a. Define P, NP and NP complete problem. b. Explain how the TSP problem can be solved using branch and bound methods. subset sum problem s = {5, 10, 12, 13, 15, 18} and d = 30.
c. Explain the back - traching algorithm. Apply the same to solve the following instance of the
(10 Marks)
*****
20f2