Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Assignment – 3

(Dynamic Programming)

1. Find an optimal solution to the 0/1 knapsack instance n , m ,


( p1 , p2 , p3 ,⋯, pn ) , and ( w1 , w2 , w3 ,⋯, wn ) . Use dynamic programming
strategy to get the optimal solution. Write a program in C or C++ to get the
optimal solution. Input the following instance of the knapsack to check the
validity where n = 7 , m = 15, ( p1 , p2 , p3 , p4 , p5 , p6 , p7 ) = (10,5,15,7,6,
18,3) , and ( w1 , w2 , w3 , w4 , w5 , w6 , w7 ) = (2, 3, 5, 7, 1, 4, 1).
2. The longest common subsequence (LCS) is defined as the longest
subsequence that is common to all the given sequences, provided that the
elements of the subsequence are not required to occupy consecutive
positions within the original sequences. Write a generalized program in C
or C++ to identify all the sub-sequences whose length is less than k, where
k is the maximum length of the subsequence.
Input, two DNA sequence R = <ACGTTCGA> and S = <BCTBBCA>.
Find the longest common DNA subsequence and all the sub-sequences
whose length is less than the maximum length of the subsequence.

You might also like