ADA_July-2003-04_2

4
Page N o . .. 1 NEW SCHEME ~ MCA44 USN F ou r thSe meste r M.C.ADegr ee Examin at io n , July/August 200 Ma s t er of Computer Applications Analysis & D sign of Algorithms Ti me : 3 hrs .] [ Max. Mar ks : 10 Note: Answer any FIVE fu l l questi o n s. 1 . (a) Explain the concept of asymptotic notations i n dicati n g the c o mmo n ly use d n o ta ti on and their signific ance. (10 Marks) (b ) O rder the followingfunctions according to their orderof growth (n-2)! , 5 1 092(n + 1 00 ) 1 0, 2 2n , 0.001n 4 +3n 3 +1, l 09 ~n, - Vn , 3 n (4 Marks) (c ) C o ns id er th e fo llo win g al go ri th m. Al g o rithm E nigma (A[O . . n 1 , O . . n -1]) II in p ut : A matrix A [ O . . n - 1 , O . . n - 1 ] o f r e al nu m bers fo r i + -- Oto n - 2 do fo r j + -- i + 1 to n - 1 do if A[i,j] t = A[j, i] return false . Return true : i) W hat do es thi s a l g orit h m c o m p ut e ? ii) What is its basic operation? iii) H owm an y t imes is th e b asic o perati o n ex ec u te d? i v) What i s tl}e ef fi c i e n cy c l ass of this alg o rit hm . v) Su gg e st an i m p ro v em e n t or a b ette r a l g or i t hm a l t o g ether and i nd i c a t e i ts efficie n c y c las s . If you cannot do it. try to prove hat in fa c t it c a n n o t b e do n e. 2. (a) Solve the f o llo wingrecurrenc e re lation : i) x(n) = 3x(n - 1) for n > 1, x(l) = 4 ii) x(n)=2x(~)+nforn>1, x(l)=l, n=2k. ( 6 Marks l (b) What is a Brute force method? When does a brute force method become applicable? ( 4 Marks (C ) Write an algorit hm f or selection sort. i) Is selection sort stab l e? ii) Is it possible to implement selection sort for linked l is t w i th the s a m efficiency as th e ar r ay vers io n.

Transcript of ADA_July-2003-04_2

Page 1: ADA_July-2003-04_2

 

Page No ... 1

NEW SCHEME ~

MCA44

USN

FourthSemester M.C.ADegree Examination, July/August 200

Master of Computer Applications

Analysis &D sign of Algorithms

Time:3 hrs.] [Max.Marks : 10

Note:

Answer any FIVE full questions.

1. (a) Explain the concept of asymptotic notations indicating the commonlyused

notation and their significance. (10 Marks)

(b) Order the followingfunctions according to their order of growth

(n-2)!, 51092(n

+ 100)10, 2

2n

, 0.001n

4

+3n

3

+1, l09~n, -Vn,3

n

(4 Marks)

(c)Consider the followingalgorithm.

Algorithm Enigma

( A [ O . .

n

1, O . .

n

- 1 ] )

II input: Amatrix A [O . .n -1, O . .n -1] of real numbers

for

i

+-- Oton -

2

do

for

j

+--

i+

1to n - 1do

if A[i,j] t= A[j, i]

return false.

Return true :

i) What does this algorithm compute?

ii)

What is its basic operation?

iii) Howmany times is the basic operation executed?

iv) What is tl}eefficiencyclass of this algorithm.

v) Suggest an improvement or a better algorithm altogether and indicateits

efficiencyclass.

Ifyou cannot do it. try to prove hat in fact it cannot be done.

2. (a) Solve the followingrecurrence relation:

i)

x(n) =3x(n -1) for n> 1, x(l) =4

ii)

x(n)=2x(~)+nforn>1, x(l)=l, n=2k.

(6 Marksl

(b) What is a Brute force method? When does a brute force method become

applicable?

(4 Marks

(C ) Write an algorithm for selection sort.

i) Is selection sort stable?

ii) Is it possible to implement selection sort for linked list with the sam

efficiencyas the array version.

Page 2: ADA_July-2003-04_2

iii) Derive the ofefficiencyclass ofselection sort. (10 Marks

Contd ....

 

(8 Marti)

Page No... 2

MCA44

3.

(a) Write quicksort algorithm and apply it to sort list E, X, A, M, P, L, E

(10 Marks)

(b) Briefly explain a method to multiply 2 large numbers based on the divide

a n d

.conquer method. Hence compute the 1234 x 2101 using the same. (10 Marka)

4.

(a) Explain how connectivity and acyclicity of a graph can be checked. (4 Marti)

(b) Write Breadth-First search algorithm and indicate its efficiency class.(8Marti)

(c) Find Topological order for the below graph using both the methods.

5. (a) Sort the followinglist usi g Heapsort. Also indicate the best-case, worst case

and average case efficiency class ofHeap sort

List ~ 5, 0, R, T, I, N, G (8Marks)

(b) Write the Horspool's algorithm to count the number of occurrence of a pattern

in the given string. Find the shift table for the pattern 'BARBER'and hence

search for the pattern 'BARBER'in the input text -

JIM ~ SAW ~ME ~ IN ~A ~BARBERSHOP (12 Markl)

6. (a) What is dynamic programming? Explain how it can be used to compute

binomial coefficient. Alsowrite the algorithm for the same.

(10 Marks)

,

(b) Solve all pairs hortest path problem fo the diagraph with the weight matrix.

[

~ ~

00 00

00 00

30000 00

3

o

2

1

2

4

o

t l

(10 Marks)

00

7. (a) Write Kruskal's algorithm to fmd minimum cost spanning tree. Find the

minimum cost spanning tree for the below graph. (10 Marks)

A .. .

Page 3: ADA_July-2003-04_2

 

Page No ... 3

MCA44

(b) Write Dijkstra's algorithm to solve single source shortest path problem. What

changes must be done to find the shortest path between 2 given vertices ofa

weighted graph?

(10 Marks)

8. (a) Compare and contrast the back tracking and brand-and-bound methods.

(4 Marks)

(b) Find one solution to 4-queens problem using state-space tree. Explain how

board's symmetry can be used tofind the second solution ton-queens problem.

Hence find the other solution to 4-queens problem. (8 Marks)

(c) Write a brief note on NP-complete problems and approximation algorithms.

(8 Marks)

Page 4: ADA_July-2003-04_2