diff --git a/Mathematics/CommonSubSeq.cpp b/Dynamic Programming/CommonSubSeq.cpp similarity index 86% rename from Mathematics/CommonSubSeq.cpp rename to Dynamic Programming/CommonSubSeq.cpp index 437dd8135..0e5ba627f 100644 --- a/Mathematics/CommonSubSeq.cpp +++ b/Dynamic Programming/CommonSubSeq.cpp @@ -1,8 +1,6 @@ -/* Implementation of LCS problem using DP*/ -#include -#include -#include +/* Implementation of LCS problem using Dynamic Programming*/ +#include using namespace std; @@ -36,11 +34,13 @@ void lcs(string X, string Y){ else j--; } + //output cout << "LCS of " << X << " and " << Y << " is " << lcs; } int main(){ string a,b; + //input two strings cin>>a; cin>>b; lcs(a,b); diff --git a/Dynamic Programming/Subset-Sum.cpp b/Dynamic Programming/Subset-Sum.cpp index 12974fb09..1896cd216 100644 --- a/Dynamic Programming/Subset-Sum.cpp +++ b/Dynamic Programming/Subset-Sum.cpp @@ -3,7 +3,9 @@ #include using namespace std; + // Returns true if there is a subset of set[] with sun equal to given sum + bool isSubsetSum(int set[], int n, int sum){ bool subset[n+1][sum+1]; for (int i = 0; i <= n; i++) @@ -24,7 +26,7 @@ bool isSubsetSum(int set[], int n, int sum){ int main() { int n,sum; - //input n - size of set and sum + //input n - size of set and sum to which it has to be compared cin>>n>>sum; int set[n]; //input elements of set