DAA La-3 0050
DAA La-3 0050
DAA La-3 0050
21BBS0050 LAB DA -3
R. ADIHTYA PAVAN
1.
#include <iostream>
#include <vector>
#include <algorithm>
int m = s1.length();
int n = s2.length();
} else {
lcs.resize(length);
int i = m, j = n;
while (i > 0 && j > 0) {
i--;
j--;
length--;
i--;
} else {
j--;
return dp[m][n];
int main() {
string s1 = "ACCGGTCGATGCGGGAACATAAC";
string s2 = "GTCGTTACC";
string lcs;
cout << "The length of the longest common subsequence is: " << result << endl;
cout << "The longest common subsequence is: " << lcs << endl;
return 0;
OUTPUT:
The overall time complexity O(m * n), indicating a linear relationship between the input sizes and the time
required to compute the longest common subsequence.
2)
#include <iostream>
#include <climits>
#include <vector>
int n = dimensions.size() - 1;
int j = i + len - 1;
dp[i][j] = INT_MAX;
dp[i][j] = cost;
int main() {
cout << "Minimum cost of matrix chain multiplication: " << minimumCost << endl;
return 0;
Output:
The time complexity is O(n^3), indicating a cubic relationship between the number of matrices and the time
required to compute the minimum cost of matrix chain multiplication.