Assignment Daa
Assignment Daa
1. Solve the recurrence relation \( T(n) = 2T(n/4) + n^{0.51} \) using the Master Theorem. Express
the recurrence in the standard form \( T(n) = aT(n/b) + f(n) \), and identify the values of \( a \), \
( b \), and \( f(n) \). Then, calculate \( \log_b a \) and compare \( f(n) \) with \( n^{\log_b a} \) to
determine which case of the Master Theorem applies. Finally, find the asymptotic complexity of
the recurrence and provide the solution.
2.For a set of keys K = {5, 10, 20, 30, 40} with frequencies F = {0.1, 0.2, 0.3, 0.2,
0.2}, use dynamic programming to find the optimal binary search tree. What is
the cost of the tree?
4.Given the strings X = "AGGTAB" and Y = "GXTXAYB", find the length of the longest
common subsequence (LCS) using dynamic programming.
6.Perform a depth-first search on the graph G = {A: [B, C], B: [D, E], C: [F], D: [], E:
[], F: []} starting from vertex A. What is the order of traversal?
7.Perform a breadth-first search on the graph G = {A: [B, C], B: [D], C: [E], D: [], E:
[]} starting from vertex A. What is the order of traversal?
8.Given a graph with 6 vertices and the following edges with weights:
[(1, 2, 10), (1, 3, 15), (2, 3, 5), (2, 4, 20), (3, 4, 10), (4, 5, 5), (5, 6, 15), (3, 6, 10)],
use Kruskal’s algorithm to find the minimum spanning tree (MST) and compute
its total weight.
9. Given the graph with vertices A, B, C, D, E and edges [(A, B, 4), (A, C, 3), (B, D, 1),
(C, E, 2), (D, E, 6)], use Prim’s algorithm starting from vertex A to find the MST
and compute its total weight.
10. Given a graph with 5 vertices and the following edges with weights:
[(1, 2, -1), (1, 3, 4), (2, 3, 3), (2, 4, 2), (4, 3, 5)], use the Bellman-Ford algorithm to
find the shortest paths from vertex 1 to all other vertices.
11. For the graph with vertices {A, B, C, D, E} and edges with weights [(A, B, 1), (B, C,
3), (C, D, 1), (A, D, 4)], apply Dijkstra’s algorithm starting from vertex A to find the
shortest paths.
14. Given a universal set U = {1, 2, 3, 4, 5} and sets S1 = {1, 2}, S2 = {2, 3}, S3 = {3, 4},
S4 = {4, 5}, find the minimum set cover using the greedy approximation
algorithm.
15. Discuss the implications of proving that P = NP. What would be the
consequences for cryptography and optimization problems?