Algorithms_in_C++ 1.0.0
Set of algorithms implemented in C++.
|
Implementation of the Subset Sum problem. More...
#include <cassert>
#include <iostream>
#include <vector>
Namespaces | |
namespace | backtracking |
for vector container | |
namespace | Subsets |
Functions for the Subset Sum problem. | |
Functions | |
uint64_t | backtracking::subset_sum::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. | |
Implementation of the Subset Sum problem.
We are given an array and a sum value. The algorithm finds all the subsets of that array with sum equal to the given sum and return such subsets count. This approach will have exponential time complexity.
int main | ( | void | ) |
uint64_t backtracking::subset_sum::number_of_subsets | ( | int32_t | sum, |
const std::vector< int32_t > & | in_arr ) |
The main function implements count of subsets.
sum | is the required sum of any subset |
in_arr | is the input array |
|
static |
Test implementations.