Experiment 2.2: Student Name: Harsh Kumar Singh UID: 21BCS11624 Section/Group: 608-B
Experiment 2.2: Student Name: Harsh Kumar Singh UID: 21BCS11624 Section/Group: 608-B
Experiment 2.2
Student Name: Harsh Kumar Singh UID: 21BCS11624
Branch: BE-CSE Section/Group: 608-B
Semester: 5th Date of Performance: 05-10-2023
Subject Name: DAA Lab Subject Code: 21CSH-311
Aim: Develop a program and analyze complexity to implement subset-sum problem using Dynamic.
Procedure/Algorithm:
#include <iostream>
#include <vector>
using namespace std;
return dp[n][targetSum];
}
int main() {
vector<int> nums = {3, 34, 4, 12, 5, 2};
int targetSum = 15;
Course Name: DAA Lab Course Code: 21ITH-311/21CSH-311
if (isSubsetSum(nums, targetSum))
cout << "Found a subset with given sum." << endl;
else
cout << "No subset found with given sum." << endl;
return 0;
}
Observations/Outcome:
Time Complexity: O(sum*n), where sum is the ‘target sum’ and ‘n’ is the size of array.
Learning Outcome: