Lab10 193
Lab10 193
Sem-Sec-Group: 5 C 2
Source Code :
#include <iostream>
#include <vector>
using namespace std;
return dp[n][W];
}
int main() {
int n, W;
cout << "Maximum value that can be obtained: " << maxValue << endl;
return 0;
}
Output:
AIM: Write a program to implement Longest Common Subsequence Problem.
Source Code :
#include <iostream>
#include <vector>
#include <string>
using namespace std;
// Create a 2D DP table
vector<vector<int>> dp(m + 1, vector<int>(n + 1, 0));
return dp[m][n];
}
return lcs;
}
int main() {
string X, Y;
int m = X.length();
int n = Y.length();
// Create a DP table
vector<vector<int>> dp(m + 1, vector<int>(n + 1, 0));
cout << "Length of Longest Common Subsequence: " << lcsLength << endl;
cout << "Longest Common Subsequence: " << lcs << endl;
return 0;
}
Output: