diff --git a/d2/d5a/subset__sum_8cpp.html b/d0/dfe/backtracking_2subset__sum_8cpp.html similarity index 91% rename from d2/d5a/subset__sum_8cpp.html rename to d0/dfe/backtracking_2subset__sum_8cpp.html index 5eeb4d8b4..f68c0e85e 100644 --- a/d2/d5a/subset__sum_8cpp.html +++ b/d0/dfe/backtracking_2subset__sum_8cpp.html @@ -71,7 +71,7 @@ $(function() {
Functions | |
| uint64_t | backtracking::subset_sum::number_of_subsets (int32_t sum, const std::vector< int32_t > &in_arr) |
| 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 () |
| static void | test () |
| Test implementations. | |
| int | main () |
| int | main () |
| Main function. | |
Main function.
|
+ Algorithms_in_C++ 1.0.0
+
+ Set of algorithms implemented in C++.
+ |
+
Implements [Sub-set sum problem] (https://en.wikipedia.org/wiki/Subset_sum_problem) algorithm, which tells whether a subset with target sum exists or not. +More...
+#include <cassert>#include <iostream>#include <vector>#include <unordered_map>+Namespaces | |
| namespace | dynamic_programming |
| Dynamic Programming algorithms. | |
| namespace | subset_sum |
| Functions for [Sub-set sum problem] (https://en.wikipedia.org/wiki/Subset_sum_problem) algorithm. | |
+Functions | |
| bool | dynamic_programming::subset_sum::subset_sum_recursion (const std::vector< int > &arr, int targetSum, std::vector< std::unordered_map< int, bool > > *dp, int index=0) |
| bool | dynamic_programming::subset_sum::subset_sum_problem (const std::vector< int > &arr, const int targetSum) |
| static void | test () |
| Test Function. | |
| int | main () |
| Main function. | |
Implements [Sub-set sum problem] (https://en.wikipedia.org/wiki/Subset_sum_problem) algorithm, which tells whether a subset with target sum exists or not.
+In this problem, we use dynamic programming to find if we can pull out a subset from an array whose sum is equal to a given target sum. The overall time complexity of the problem is O(n * targetSum) where n is the size of the array. For example, array = [1, -10, 2, 31, -6], targetSum = -14. Output: true => We can pick subset [-10, 2, -6] with sum as (-10) + 2 + (-6) = -14.
+| int main | +( | +void | +) | ++ |
| bool dynamic_programming::subset_sum::subset_sum_problem | +( | +const std::vector< int > & | +arr, | +
| + | + | const int | +targetSum | +
| + | ) | ++ |
Function implementing subset sum algorithm using top-down approach
| arr | input array |
| targetSum | the target sum of the subset |
| bool dynamic_programming::subset_sum::subset_sum_recursion | +( | +const std::vector< int > & | +arr, | +
| + | + | int | +targetSum, | +
| + | + | std::vector< std::unordered_map< int, bool > > * | +dp, | +
| + | + | int | +index = 0 |
+
| + | ) | ++ |
Recursive function using dynamic programming to find if the required sum subset exists or not.
| arr | input array |
| targetSum | the target sum of the subset |
| dp | the map storing the results |
+
|
+ +static | +
Test Function.
+|
+ Algorithms_in_C++ 1.0.0
+
+ Set of algorithms implemented in C++.
+ |
+
Functions for [Sub-set sum problem] (https://en.wikipedia.org/wiki/Subset_sum_problem) algorithm. +More...
+Functions for [Sub-set sum problem] (https://en.wikipedia.org/wiki/Subset_sum_problem) algorithm.
+Dynamic Programming algorithms.
Dynamic programming algorithms.
+for unordered map
for std::vector
Dynamic Programming algorithm.
Dynamic Programming Algorithms.
@@ -124,6 +125,8 @@ Functionsfor assert for std::max for IO operations
Dynamic Programming algorithms
for assert for IO operations
+Dynamic Programming algorithms
+for std::assert for IO operations for std::vector
Dynamic Programming algorithms