int32_t nelement = in_arr.size();
36uint64_t count_of_subset = 0;
38 for(int32_t i = 0; i < (1 << (nelement)); i++) {
40 for(int32_t j = 0; j < nelement; j++) {
49 returncount_of_subset;
60std::cout <<
"1st test ";
61std::vector<int32_t> array1 = {-7, -3, -2, 5, 8};
65std::cout <<
"passed"<< std::endl;
68std::cout <<
"2nd test ";
69std::vector<int32_t> array2 = {1, 2, 3, 3};
73std::cout <<
"passed"<< std::endl;
76std::cout <<
"3rd test ";
77std::vector<int32_t> array3 = {1, 1, 1, 1};
81std::cout <<
"passed"<< std::endl;
84std::cout <<
"4th test ";
85std::vector<int32_t> array4 = {3, 3, 3, 3};
89std::cout <<
"passed"<< std::endl;
92std::cout <<
"5th test ";
93std::vector<int32_t> array5 = {};
97std::cout <<
"passed"<< std::endl;
Functions for [Sub-set sum problem] (https://en.wikipedia.org/wiki/Subset_sum_problem) algorithm.
uint64_t number_of_subsets(int32_t sum, const std::vector< int32_t > &in_arr)
The main function implements count of subsets.
static void test()
Test implementations.
int main()
Main function.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4