CSE303 ADA Assignment (Module3+4+5)
CSE303 ADA Assignment (Module3+4+5)
Assignment [Module 3]
[Deadline submission: 25 Oct, 2024]
Q.1 (a) Consider two strings 𝑋 = (2,2,1,1,2,1,2,1) and 𝑌 = (2,1,1,2,2,1,1,2,1). Let 𝑙 be the length
of the longest common subsequence between X and Y and n be the number of such common
subsequences between X and Y. Then find the value of (𝑙 + 10𝑛).
(b) Determine LCS for the sequence
Q.2 What is “principle of optimality”? Write a pseudo code for finding all pair shortest path
using Floyed algorithm. Apply this algorithm for the following graph. Analyze its time-
complexity also.
Q.4 Solve the following instance of 0/1 knapsack problem using dynamic programming:
Number of objects n=5, Knapsack capacity M=10,
Profit P = (1,6,18,22,28) and weight W = (1,2,5,6,7)
Q.5 Explain how TSP problem is solved using dynamic programming? Find the solution of the
following TSP problem where adjacency matrix is given as:
0 2 2 4
3 0 6 2
[ ]
2 5 0 4
5 4 3 0
*************************************
1
Assignment 4
[Deadline submission: 25 Oct, 2024]
Q1. Differentiate between DFS and BFS with respect to Time and space complexity (b is a branching
factor and m is the depth of the sallowest goal node).
Q2. Given the following graph where A is the starting node and K is the goal node.
Trace Graph-Search algorithm using BFS and DFS strategies. In each case, show the order in which
nodes are added to the fringe as well as the generated tree and the solution path. Leftmost nodes are
added before rightmost ones. Indicate if found solutions are optimal.
Q3. Design an algorithm that uses DFS to find all strongly connected components of a directed graph.
Backtracking
Q4. Let n=6 and w[1:6]=[5,10,15,20,25,12] and m=35. Find all possible subsets of w such that sum
will be equals to m. Draw the state space tree also.
Q5. Consider three items <I1, I2, I3,I4> with the respective weights and values as <W1=2, W2=3,
W3=4,W4=5> and <V1=3, V2=5, V3=6,V4=10>. The knapsack capacity is W=8. Apply backtracking
approach to obtain optimal solution.
Q6. For which values of n does the n queen problem have no solutions? Draw a state space tree for 4
queen’s problem (avoid same row, same column, and diagonal) using backtracking. Write two possible
solutions of 8 Queen’s problem.
2
Branch & Bound
Q.7: Solve the following instance of 0/1 Knapsack problem using Branch and bound.
Knapsack Capacity W=16.
Module5 (Assignment)
[Deadline submission: 25 Oct, 2024]
Q.1 Differentiate between P, NP, NP-C and NP-Hard Problems with a suitable diagram.
Q.2 State Cook-Levin Theorem.
Q.3 Consider a well-known NP-Hard problem SAT. If 𝐿 ∈ 𝑁𝑃 𝑎𝑛𝑑 𝑆𝐴𝑇 ≼𝑃 𝐿 then what we can say
about class of problem L?
Q.4 Show that the following problem is NP-Complete (Any two of the following)
(i) CLIQUE problem (ii) Vertex cover problem (VCP)
(iii) Hamiltonian cycle problem (iv) TSP