Jawaharlal Nehru Technological University Hyderabad
Jawaharlal Nehru Technological University Hyderabad B.Tech III DESIGN AND ANALYSIS OF ALGORITHMS Previous Question Paper (February - 2022 - R16)
Answer any five questions. All questions carry equal marks.
Main
Give Strassen’s matrix multiplication algorithm and derive the time complexity.
Answer
Strassen's algorithm is a divide-and-conquer approach to matrix multiplication that reduces the number of recursive multiplications from 8 to 7. Given two n x n matrices A and B, we divide them into four n/2 x n/2 submatrices. The product C = AB is computed by calculating seven intermediate products P1 through P7:
The resulting submatrices of C are then formed by linear combinations of these products. The recurrence relation for the time complexity is T(n) = 7T(n/2) + O(n2). Applying the Master Theorem where a=7, b=2, and f(n)=n2, we compare nlog2(7) with n2. Since log2(7) is approximately 2.81, which is greater than 2, the complexity is T(n) = O(nlog2(7)) ≈ O(n2.81), which is more efficient than the standard O(n3) algorithm.
Illustrate with an example the working of quick sort.
Answer
Quick sort uses a divide-and-conquer strategy by selecting a pivot element and partitioning the array such that elements smaller than the pivot are on the left and larger elements are on the right. Consider the array [25, 10, 5, 30, 15].
- Select the last element 15 as the pivot.
- Partitioning: Compare elements with 15. 10 and 5 are smaller, 25 and 30 are larger. Swap 25 with 10, then 30 with 15. The array becomes [10, 5, 15, 30, 25].
- The pivot 15 is now in its correct sorted position.
- Recursively apply the same logic to the left sub-array [10, 5] and the right sub-array [30, 25].
- For [10, 5], pivot 5 results in [5, 10]. For [30, 25], pivot 25 results in [25, 30].
- Combining the results, the final sorted array is [5, 10, 15, 25, 30].
The average time complexity is O(n log n), while the worst-case complexity is O(n2) when the pivot selection consistently results in unbalanced partitions.
Explain various asymptotic notations for algorithm analysis.
Answer
Sign in to view the complete answer paper.
Derive the time complexity of binary search.
Answer
Sign in to view the complete answer paper.
Give the solution to the 8-queens problem using backtracking.
Answer
Sign in to view the complete answer paper.
Explain the solution to the graph coloring problem using backtracking.
Answer
Sign in to view the complete answer paper.
Explain the Single source shortest path problem with an example.
Answer
Sign in to view the complete answer paper.
What is the need for generating a spanning tree? Explain an algorithm for generating spanning tree.
Answer
Sign in to view the complete answer paper.
Discuss the time and space complexity of Dynamic Programming traveling sales person algorithm.
Answer
Sign in to view the complete answer paper.
Explain the LC branch and bound algorithm.
Answer
Sign in to view the complete answer paper.