Question Bank DAA Module III & IV
Question Bank DAA Module III & IV
8. Given two sequences: "AGGTAC" and "GTACGG." Apply the dynamic programming algorithm for LCS
and provide the LCS length and the LCS itself.
String1: b q d r c v e f g h
String2: a b c v d e f g h
10. Consider the sequences: "ABCDEF" and "XBCDXYZEF." Using the dynamic programming approach,
compute the LCS length and provide the LCS for the given sequences.
14. Prove that the fractional knapsack problem has the greedy-choice property.
15. : Find the maximum profit by placing below objects into the knapsack size 20.
Objects O1 O2 O3
Weight 18 15 10
Profit 25 24 15
17. Calculate the total no. of bits required to store the following data set using Huffman encoding and each
letter required 3 bits for their representation
letter A B C D E
frequenc 20 2 10 5 12
y
18. What is an optimal Huffman code for the following set of frequencies, based on the first 8 Fibonacci
numbers?
a:1 b:1 c:2 d:3 e:5 f:8 g:13 h:21
Can you generalize your answer to find the optimal code when the frequencies are the first n Fibonacci
numbers?
19. Prove that for an optimal code, if the characters are ordered so that their frequencies are nonincreasing,
then their codeword lengths are nondecreasing.
20. What is the running time of BFS if its input graph is represented by an adjacency matrix and the algorithm
is modified to handle this form of input?
21. Show that in an undirected graph, classifying an edge (u, v) as a tree edge or a back edge according to
whether (u, v) or (v, u) is encountered first during the depth-first search is equivalent to classifying it
according to the priority of types in the classification scheme.
22. Explain the concept of level order traversal and how it relates to Breadth-First Search (BFS).
23. Describe how the visited status of vertices is typically maintained in the BFS algorithm.
24. Compare and contrast Breadth-First Search (BFS) and Depth-First Search (DFS) algorithms.
25. Write the data structure name(s) through which BFS and DFS graph traversal property will be
implemented.
29. : Find a valid BFS sequence of node for following graph and consider node N as root node.
30. Describe the concept of backtracking in the context of Depth-First Search (DFS).
31. Find a valid DFS sequence of node for following graph and consider node 0 as root node.
32. Discuss the time complexity of DFS on a graph with V vertices and E edges, and provide a brief
explanation.
34. Discuss the significance of using a stack data structure in implementing DFS.
35. Let (u, v) be a minimum-weight edge in a graph G. Show that (u, v) belongs to some minimum spanning
tree of G.
36. Show that if an edge (u, v) is contained in some minimum spanning tree, then it is a light edge crossing
some cut of the graph.
37. (i)Write the properties of spanning tree.
(ii)For any complete graph G (V, E) has 4 No. of vertices then calculate total No. of Possible spanning
tree(s).
38. Kruskal’s algorithm can return different spanning trees for the same input graph G, depending on how ties
are broken when the edges are sorted into order. Show that for each minimum spanning tree T of G, there is
a way to sort the edges of G in Kruskal’s algorithm so that the algorithm returns T.
39. Consider the following graph and find out correct edge sequence of Prim’s algorithm.
40. Given the following weighted graph, illustrate the Minimum Spanning Tree (MST) using Prim's algorithm
41. For the following weighted graph, show the Minimum Spanning Tree (MST) using Kruskal's algorithm:
42. Discuss the conditions under which a graph may have multiple Minimum Spanning Trees (MSTs).
43. Consider the following graph and find out correct edge sequence of Kruskal’s algorithm.
44. Construct a Minimum Spanning Tree for the following graph, using Kruskals’ algorithm starting from
vertex ‘a’
45. Construct a Minimum cost Spanning Tree for following graph, from vertex 4 using Prims’ algorithm
46. Discuss the application of Minimum Spanning Trees (MSTs) in real-world scenarios.
47. Suppose that the graph G = (V, E) is represented as an adjacency matrix. Give a simple implementation of
Prim’s algorithm for this case that runs in O(V2) time.
48. Explain how Dijkstra's algorithm handles negative edge weights and discuss its limitations in such
scenarios.
49. In what order do the nodes get included if we run, Dijkstra Single Source Shortest path on the above graph
on vertex ‘a’.
Apply Dijkstra's algorithm to find the shortest path from Node 0 to Node 7 and provide the shortest path length.