int main() { int set[] = {3, 34, 4, 12, 5, 2}; int sum = 9; int n = sizeof(set)/sizeof(set[0]); if (isSubsetSum_recursive(set, n, sum) == true) printf("success by recursive"); else if(isSubsetSum_dp(set, n, sum) == true) printf("success by recursive"); else printf("No subset with given sum"); getchar(); return 0; }
// Driver program to test above function int main() { int set[] = {3, 34, 4, 12, 5, 2}; int sum = 9; int n = sizeof(set)/sizeof(set[0]); if (isSubsetSum_re(set, n, sum) == true) printf("Recursive: Found a subset with given sum\n"); else printf("Recursive: No subset with given sum\n"); if (isSubsetSum_dp(set, n, sum) == true) printf("DP: Found a subset with given sum\n"); else printf("DP: No subset with given sum\n"); return 0; }