daa prev final.docx

8
UNIT-I 1. a) Describe Merge sort algorithm using Divide-and-conquer Strategy 6 b) Explain how the above merge sort algorithm sorts the following numbers 5,8,6,3,7,2 6 OR 2. a) What is an algorithm ? State & Explain basic properties of an algorithm 6 b) Explain the Space & time complexities 1. a) Consider sorting n numbers stored in array A by first finding the smallest element of A and exchanging it with the element in A [1]. Then find the second smallest element of A, and exchange it with A[2]. Continue in this manner for the first n-1 elements of A. Write pseudocode for this algorithm, which is known as selection sort. What loop invariant does this algorithm maintain? Why does it need to run for only the first n-1 elements, rather than for all n elements? Give the best-case and worst-case running times of selection sort in Θ-notation 8 b) Insertion sort can be expressed as a recursive procedure as follows. In order to sort A [1…..n], we recursively sort A [1….n-1] and then insert A[n] into the sorted array A [1…n-1]. Write a recurrence for the running time of this recursive version of insertion sort 4 OR 2. Write the Quick Sort algorithm and show that Quick Sort’s best- case running time is Ω(n log n) 6+6 1. a) Explain the general method of divide and conquer 6 b) Solve Binary Search (Searching for a key) using divide and conquer and generate a solution with your own example 6 OR 2. a) Explain Asymptotic notations with illustrations. Solve finding the minimum and maximum value in a set using divide and conquer strategy consider your own illustration 6 b) Solve Strassen’s matrix multiplication 1. a) Explain the general method of divide and conquer 6 b) Solve Binary Search (Searching for a key) using divide and conquer and generate a solution with your own example 6 OR 2. a) Explain Asymptotic notations with illustrations. Solve finding the minimum and maximum value in a set using

Transcript of daa prev final.docx

UNIT-I1. a) Describe Merge sort algorithm using Divide-and-conquer Strategy 6 b) Explain how the above merge sort algorithm sorts the following numbers 5,8,6,3,7,2 6 OR 2. a) What is an algorithm ? State & Explain basic properties of an algorithm 6 b) Explain the Space & time complexities

1. a) Consider sorting n numbers stored in array A by first finding the smallest element of A and exchanging it with the element in A [1]. Then find the second smallest element of A, and exchange it with A[2]. Continue in this manner for the first n-1 elements of A. Write pseudocode for this algorithm, which is known as selection sort. What loop invariant does this algorithm maintain? Why does it need to run for only the first n-1 elements, rather than for all n elements? Give the best-case and worst-case running times of selection sort in -notation 8 b) Insertion sort can be expressed as a recursive procedure as follows. In order to sort A [1..n], we recursively sort A [1.n-1] and then insert A[n] into the sorted array A [1n-1]. Write a recurrence for the running time of this recursive version of insertion sort 4 OR 2. Write the Quick Sort algorithm and show that Quick Sorts best-case running time is (n log n) 6+61. a) Explain the general method of divide and conquer 6 b) Solve Binary Search (Searching for a key) using divide and conquer and generate a solution with your own example 6 OR 2. a) Explain Asymptotic notations with illustrations. Solve finding the minimum and maximum value in a set using divide and conquer strategy consider your own illustration 6 b) Solve Strassens matrix multiplication

1. a) Explain the general method of divide and conquer 6 b) Solve Binary Search (Searching for a key) using divide and conquer and generate a solution with your own example 6 OR 2. a) Explain Asymptotic notations with illustrations. Solve finding the minimum and maximum value in a set using divide and conquer strategy consider your own illustration 6 b) Solve Strassens matrix multiplication

1. a) Analyze the Quick sort algorithm for its average case performance 6 b) Discuss an effective technique for finding maximum and minimum in a set of numbers 6 OR 2. Apply the Strassens matrix multiplication technique for multiplying n x n matrices showing each step in detailUNIT-23. a) Describe the Kruskals algorithms for finding the minimum spanning tree 6 b) Describes the Prims algorithms for finding the minimum spanning tree 6 OR 4. a) Explain the greedy technique with Kuapsack problem as an example 6 b) What is the solution generated by the function Job sequencing when N=7, (P1, P2, .. P7) = (3, 5, 20, 18, 1, 6, 30) and (d1, d2, d7) = (1, 3, 4, 3, 2, 1, 2) 63. Suppose that in a 0-1 knapsack problem, the order of the items when sorted by increasing weight is the same as their order when sorted by decreasing value. Give an efficient algorithm to find an optimal solution to this variant of the knapsack problem, and argue that your algorithm is correct 12 OR 4. Write the Dijkstras algorithm and its time and space complexity3. Explain the Dijkstras algorithm for single-source shortest path problem with an example. Compare Dijkstras with Floyds 12 OR 4. a) Explain the General Greedy method with an Algorithm 6 b) Solve Job sequencing with deadlines using the above technique with your own example 63. Solve the job sequencing problem for the given data n = 5, profits (1,5,20,15,10) and deadlines (1,2,4,1.3) using greedy strategy 12 OR 4. Explain in detail about various minimum cost spanning trees. Give two types. Give the algorithm and explain the types with your own diagram. Differentiate them

3. Explain the general principle of Greedy algorithm. Show its application to a job sequencing problem 12 OR 4. What is a Spanning tree? Explain a procedure to determine a minimum cost spanning tree 12

UNIT-3

5. a) Write the algorithm for Optimal Binary Search Tree 6 b) Show that the computing time of function OBST is ( n2 ) 6 OR 6. a) What are the differences between dynamic programming and divide-and-conquer techniques 2 b) Design a dynamic programming algorithm and explain for finding an optimal order of multiplying n matrices5. Write the algorithm for Multistage graph corresponding to forward and backward approaches 12 OR 6. Write and explain the dynamic programming algorithm for computing a binomial coefficient. Obtain the time efficiency of the algorithm5. a) Explain the general method of Dynamic Programming 6b) Consider three stages of a system with1 0.3, 2 0.5 3 0.21 30 2 20 3 30r r rc c cWhere the total cost of the system is C=80 and and u1=2,u2=3, u3=2find the reliability design 6OR6. Compute w(i,j), c(i,j), r(i,j) for the identifier set n = 4,(a1,a2,a3,a4) = {cout, float, int, while} with P(1:4) = {2,1,1,2}and q = {2,3,1,1,1}. Using the r (i,j) s construct the optimal binarysearch tree

5. a) Explain the detail about travelling salesperson problem with suitable example 6 b) Explain the technique of dynamic programming for all pairs shortest path in a graph 6 OR 6. Consider the three stages of a system with (r1,r2,r3) = (0.2,0.5,0.3) and (c1,c2,c3) = (20,30,20) where the total cost of system 70 and (u1,u2,u3) = (3,2,2) find the reliability design

5. What is an Optimal binary search tree? What is its significance? Write a procedure to build such a tree 12 OR 6. State the all pairs shortest path problem. Discuss a method to find solution to the all pairs shortest path problem

UNIT-4

7. a) Explain the Back Tracking Strategy 4 b) State and explain the n-Queen problem using backtracking 8 OR 8. Write the Depth First Search algorithm and its time and space Complexity7. a) Explain the Back Tracking Strategy 4 b) State and explain the Graph coloring problem using backtracking 8 OR 8. Describe the Kruskals and Prims algorithms for finding the minimum spanning tree7. a) Explain the general method of Backtracking. Illustrate the above method for solving eight queens problems 6 b) Using the above technique, find all possible sum of subsets for 3 items {1,2,3} where the total sum of subsets is 6 6 OR 8. a) Explain the representation of graphs 6 b) Generate the biconnected components and articulation points using depth-first search tree

7. Enumerate and solve the problems using back tracking a) 8-queens problem b) Hamiltonian circuit problem 12 OR 8. Let M=81, weight W=(7,11,13,24) draw a portions of state space tree using algorithm of sum of subsets in Back tracking. Clearly show the solutions obtained7. a) Write a non-recursive Preorder traversal algorithm for a binary tree 6 b) What is a spanning tree? Write a method to generate a spanning tree of a given graph 6 OR 8. a) State the graph coloring problem. Discuss the complexity of solving such a problem 6 b) State the eight queen problem. Is it a NP hard problem? Justify your answer

UNIT-5

9. a) Explain the Branch and Bound technique 4 b) Explain the Branch and Bound Technique using traveling salesman problem as an example 4 OR 10. Give an algorithm for Lagrange and Newtonian interpolation9. Give an algorithm for Lagrange and Newtonian interpolation 6+6 OR 10. a) Write the differences between backtracking and branch-and-bound techniques 2 b) Apply the branch-and-bound techniques in solving the Traveling salesman problem9. Explain the general method of Branch and Bound. Generate FIFO BB on the problem Travelling Sales Person, and find the solution space 12 OR 10. a) Compare FIFOBB and LIFOBB for the Branch and Bound Technique 6 b) How efficiency can be improved using Branch and Bound compared to the other optimization techniques

9. Explain the terms FIFO branch and bound, LC branch and bound and LC search 12 OR 10. Explain in detail with an algorithm about decision problem9. Analyze the efficiency of Branch and Bound approach in solving problems. Explain, how this technique can be applied in graph search 12 OR 10. Explain the applicability of interpolation method for solving algebraic problem