-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinterval_subset_sum_problem.h
42 lines (36 loc) · 1.36 KB
/
interval_subset_sum_problem.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#ifndef CPP_ALGORITHM_INTERVAL_SUBSET_SUM_PROBLEM_H
#define CPP_ALGORITHM_INTERVAL_SUBSET_SUM_PROBLEM_H
#include <vector>
namespace IntervalSubset
{
/**
* \brief Find the maximum sum of a contiguous subsequence in a given sequence.
* \param seq integer sequence
* \return maximum sum of subset
*/
auto SubsetSum1(const std::vector<int>& seq) -> int;
/**
* \brief Find the maximum sum of a contiguous subsequence in a given sequence.
* \param seq integer sequence
* \return maximum sum of subset
*/
auto SubsetSum2(const std::vector<int>& seq) -> int;
/**
* \brief Find the maximum sum of a contiguous subsequence in a given sequence.
* This algorithm uses a divide-and-conquer approach.
* \details This approach calculates left subset, right subset and cross subset.
* \param seq integer sequence
* \param low lower index
* \param high higher index
* \return maximum sum of subset
*/
auto DivideAndConquerSubsetSum(const std::vector<int>& seq, int low, int high) -> int;
/**
* \brief Find the maximum sum of a contiguous subsequence in a given sequence.
* This algorithm uses a dynamic programming approach.
* \param seq integer sequence
* \return maximum sum of subset
*/
auto DynamicProgrammingSubsetSum(const std::vector<int>& seq) -> int;
}
#endif