Arun Exp-6
Arun Exp-6
Arun Exp-6
Experiment-6
Student Name: Arun UID: 22BET10320
Branch: IT Section/Group:22BET_IoT_703/B
Semester: 5th Date of Performance: 10/09/2024
Subject Name: DAA Subject Code: 22CSH-311
3. Implementation/Code:
#include <iostream>
#include <vector>
using namespace std;
void printSubsets(vector<int>& arr, vector<vector<bool>>& dp, int i, int j,
vector<int>& subset) {
if (j == 0) {
cout << "{ ";
for (int num : subset) {
cout << num << " ";
}
cout << "}" << endl;
return;
}
if (i == 0) return;
if (dp[i-1][j]) {
printSubsets(arr, dp, i-1, j, subset);
}
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
int main() {
vector<int> arr = {9, 44, 6, 64, 27, 6, 100};
int sum = 100;
if (!subsetSum(arr, sum)) {
cout << "No subset with the given sum" << endl;
}
return 0;
}
4. Output: