JNTU
JNTU B.Tech III DESIGN AND ANALYSIS OF ALGORITHMS Previous Question Paper (October - 2020 - R16)
Answer any five questions
All questions carry equal marks
Main
Explain the general method of divide and conquer with an example.
Answer
The Divide and Conquer paradigm is an algorithmic strategy that solves a problem by recursively breaking it down into two or more sub-problems of the same type, until these become simple enough to be solved directly. The solutions to the sub-problems are then combined to give the solution to the original problem.
The general method follows three steps:
- Divide: Break the problem into smaller sub-problems that are instances of the same problem.
- Conquer: Solve the sub-problems recursively. If the sub-problems are small enough, solve them as base cases.
- Combine: Merge the solutions of the sub-problems to obtain the final solution for the original problem.
An example is Merge Sort. To sort an array of size n, it divides the array into two halves, recursively sorts each half, and then merges the two sorted halves into a single sorted array.
Write an algorithm for Strassen's matrix multiplication and analyze the complexity of your algorithm.
Answer
Strassen's algorithm improves matrix multiplication by reducing the number of recursive multiplications required. Given two n x n matrices A and B, we divide them into four n/2 x n/2 sub-matrices. The algorithm computes seven products P1 through P7:
P2 = (A21 + A22)B11
P3 = A11(B12 - B22)
P4 = A22(B21 - B11)
P5 = (A11 + A12)B22
P6 = (A21 - A11)(B11 + B12)
P7 = (A12 - A22)(B21 + B22)
The resulting sub-matrices of C are then calculated using additions and subtractions of these products:
C12 = P3 + P5
C21 = P2 + P4
C22 = P1 - P2 + P3 + P6
The recurrence relation for the time complexity is:
Using the Master Theorem, where a = 7, b = 2, and f(n) = O(n²), we compare log base 2 of 7 (≈ 2.81) with 2. Since 2.81 > 2, the time complexity is O(n^log₂7), which is approximately O(n^2.81), making it more efficient than the standard O(n³) approach for large matrices.
List the disjoint set operations and explain with examples.
Answer
Sign in to view the complete answer paper.
Explain GRAPH coloring problem with example. Analyze the running time for that problem/algorithm.
Answer
Sign in to view the complete answer paper.
Differentiate between Prim’s algorithm and Kruskal's algorithm for finding the minimum cost spanning tree.
Answer
Sign in to view the complete answer paper.
Write an algorithm of all pairs shortest path problem.
Answer
Sign in to view the complete answer paper.
Solve the following 0/1 Knapsack problem using dynamic programming P= (11, 21, 31, 33), W= (2, 12, 23, 15), C=42, n=4.
Answer
Sign in to view the complete answer paper.
Compare NP Hard and NP Complete.
Answer
Sign in to view the complete answer paper.
Explain about 0/1 Knapsack Problem using branch and bound with example.
Answer
Sign in to view the complete answer paper.
Explain the merge sort algorithm with an example. Design an algorithm for merge sort.
Answer
Sign in to view the complete answer paper.
Explain the major drawbacks of backtracking method with example.
Answer
Sign in to view the complete answer paper.
Write an algorithm for sum of subsets problem.
Answer
Sign in to view the complete answer paper.
Write an algorithm for Knapsack problem using Greedy method.
Answer
Sign in to view the complete answer paper.
Find the optimal solution by using Prim's minimum cost spanning of the following graph.
Answer
Sign in to view the complete answer paper.