analysis and design of algorithm paper 3

Embed Size (px)

Citation preview

  • 8/3/2019 analysis and design of algorithm paper 3

    1/2

    USN 0 6 C S 4 3

    Fourth Semester BE. Degree Examination, June-July 2009Analysis and Design of AlgorithmsTm 3hs Mx Mrks100

    Note: Answer any FIVE full questions selecting at least TWO from each part.PART - A

    1 a. With figure, explain algorithm development process. ( 10 Marks )b. Explain how priority Queue can be implemented as unsorted array. ( 06 Marks )c. Find GCD (60, 24) by applying Euclid's formula. Estimate the number of times computation

    is done in Euclid's method and in an algorithm based on checking consecutive integers from

    2 a .min (m, n) down to gcd ( m, n).Explain all asymptotic notations used in algorithm analysis.

    ( 0 4 M a r k s )(06 Marks)

    b. Consider the following algorithmAlgorithm Enigma (A[0 n -1, 0 n -1] )fori+- 0ton-2 do

    for j F i + 1 to n-1 doifA[i,j]#A[j.i]

    return falseend for

    end forreturn true

    end algorithmi) What does this algorithm compute?ii) What is its basic operationiii) How many times is the basic operation executed?iv) What is the efficiency class of this algorithm?v) Can this algorithm be further imported?10MrkConsider the following recursive algorithm for computing the sum of the first n cubes.S(n)=13+23+33+.......+n3Algorithm S (n)

    if (n = 1) return 1else return (S (n-1) + n * n * n)end a lgorithmSet up and solve a recurrence relation for the number of times the algorithm's basicoperatonsexecued (4 M a r k s )

    3 a. Write the Quick sort algorithm. Trace the same on data set - 5, 3, 1, 9, 8, 2, 4, 7. (10 Marks)b. Wite an algorithmto find the height of Bnary tree. (04 Marks)c. Outline an exhaustive search algorithm to solve Travelling salesman problem. ( 06 Marks )

    4 a. Consider a set of 13 elements in an array list the elements of array that require the largestnumber of key comparisons when searched for by Binary search. Find the average numberof key comparisons made by binary search in successful search and unsuccessful search inhsaay 6 M a r k s)b Wite depthfirst searchalgorithm (8 Marks )

    c. Briefly explain how breadth first search can be used to check connectness of a graph andalso to find the number of components in a graph. (06 Marks )I of 2

  • 8/3/2019 analysis and design of algorithm paper 3

    2/2

    0 6 C S 4 3PART - B

    5 a. Design a Presorting - based algorithm to find the distance between the 2 closest numbers inan array of `n' numbers. Compare the efficiency of this algorithm. With that of brute - forceagohm

    0 M arks)b. Construct AVL tree for the set of elements - 5, 6, 8, 3, 2, 4, 7. (06 Marks)c. Apply Horspool's algorithm to search for the pattern BAOBAB in the text

    BESS b KNEWb ABOUTb BAOBABSAlso, find the total number of comparisons made. (04 Marks)

    6 a . For the input - 30, 20, 56 , 75, 31, 19 construct the open hash table. Find largest and av eragenumber of key comparisons in a successful search in the table. (06 Marks)b ExplainDynamc programmng (4 Marks)

    c, Write the formula to find the shortest path using Floyd's approach. Use Floyd's method tosolve the below a ll-pairs shortest paths problem.(10Mrk)0 oo 3 oo2 0 00 0000 7 0 1

    L 6 0 -7 a. Use Kruskal's method to find min cost spanning tree for the below graph . (06 Marks)

    b. Write Huffinan tree construction algorithm.(08Mrk)c. Draw the decision tree for the 3 - elements insertion sort. (06 Marks)

    8 a. Differentiate between back tracking and Branch - and - bound algorithm. (06 Marks)b. Draw the state space tree to generate first solution to 4 - queens problem. With the firstsolution, generate another solution, making use of board's symmetry . (08 Marks)c. ExplainPandNPproblem. (6 Marks)

    2 of 2