A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://TheAlgorithms.github.io/C-Plus-Plus/d2/d5a/subset__sum_8cpp_source.html below:

TheAlgorithms/C++: backtracking/subset_sum.cpp Source File

Go to the documentation of this file. 35

int32_t nelement = in_arr.size();

36

uint64_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 return

count_of_subset;

60

std::cout <<

"1st test "

;

61

std::vector<int32_t> array1 = {-7, -3, -2, 5, 8};

65

std::cout <<

"passed"

<< std::endl;

68

std::cout <<

"2nd test "

;

69

std::vector<int32_t> array2 = {1, 2, 3, 3};

73

std::cout <<

"passed"

<< std::endl;

76

std::cout <<

"3rd test "

;

77

std::vector<int32_t> array3 = {1, 1, 1, 1};

81

std::cout <<

"passed"

<< std::endl;

84

std::cout <<

"4th test "

;

85

std::vector<int32_t> array4 = {3, 3, 3, 3};

89

std::cout <<

"passed"

<< std::endl;

92

std::cout <<

"5th test "

;

93

std::vector<int32_t> array5 = {};

97

std::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