JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY HYDERABAD
JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY HYDERABAD B.Tech IV ADVANCED ALGORITHMS Previous Question Paper (February/March - 2022 - R18)
Answer Any Five Questions. All Questions carry equal marks.
Main
Write an algorithm of OBST.
Answer
The Optimal Binary Search Tree (OBST) algorithm constructs a binary search tree with minimum search cost given a set of keys and their associated probabilities. Let P[i] be the probability of searching for key i and Q[i] be the probability of searching for a value between keys i and i+1.
- Initialize a cost table C[1..n+1, 0..n] and a root table R[1..n, 1..n] to zero.
- For i = 1 to n, set C[i, i-1] = Q[i-1] and W[i, i-1] = Q[i-1].
- For length L = 1 to n:
- For i = 1 to n-L+1:
- Set j = i+L-1.
- Calculate W[i, j] = W[i, j-1] + P[j] + Q[j].
- Find k in range [i, j] that minimizes C[i, k-1] + C[k+1, j].
- Set C[i, j] = W[i, j] + min(C[i, k-1] + C[k+1, j]) and R[i, j] = k.
Derive the time complexity of quick sort in an average case.
Answer
The average case time complexity of Quick Sort is derived using the recurrence relation T(n) = (n-1) + (1/n) ∑ [T(i-1) + T(n-i)] for i=1 to n, where (n-1) is the partitioning cost.
- The recurrence simplifies to T(n) = (n-1) + (2/n) ∑ T(i) for i=0 to n-1.
- Multiplying by n gives nT(n) = n(n-1) + 2 ∑ T(i).
- Subtracting the equation for (n-1): (n-1)T(n-1) = (n-1)(n-2) + 2 ∑ T(i).
- This results in nT(n) - (n-1)T(n-1) = 2(n-1) + 2T(n-1).
- Rearranging gives nT(n) = (n+1)T(n-1) + 2(n-1).
- Dividing by n(n+1) yields T(n)/(n+1) = T(n-1)/n + 2(n-1)/(n(n+1)).
- Summing this telescopic series results in T(n) ≈ 2n ln n, which is O(n log n).
What is the running time of HEAPSORT on an array A of length n that is already sorted in increasing order? What about decreasing order?
Answer
Sign in to view the complete answer paper.
Use the substitution method to solve the following recurrence relation
Answer
Sign in to view the complete answer paper.
Write an algorithm of Activity selection algorithm.
Answer
Sign in to view the complete answer paper.
Explain about Topological sorting.
Answer
Sign in to view the complete answer paper.
State and explain Prim’s algorithm with an example.
Answer
Sign in to view the complete answer paper.
Write an algorithm of single source shortest path.
Answer
Sign in to view the complete answer paper.
Illustrate the zero-one principle with an example. Prove that an n-input sorting network must contain atleast one comparator between the i-th and (i + 1)-st lines for all i = 1, 2, . . . , n - 1.
Answer
Sign in to view the complete answer paper.
Explain about Comparision Network.
Answer
Sign in to view the complete answer paper.
Derive the strassen’s matrix multiplication.
Answer
Sign in to view the complete answer paper.
Explain the applications of merging networks.
Answer
Sign in to view the complete answer paper.
Write an algorithm of Rabin-Karp and also illustrate with an example.
Answer
Sign in to view the complete answer paper.
What is the vertex-cover problem? Give an example of a graph for which APPROX-VERTEX-COVER always yields a suboptimal solution.
Answer
Sign in to view the complete answer paper.
Illustrate an Algorithm that computes the traveling-salesman problem with triangle inequality.
Answer
Sign in to view the complete answer paper.