-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMaxSubarray.h
More file actions
46 lines (39 loc) · 1.46 KB
/
Copy pathMaxSubarray.h
File metadata and controls
46 lines (39 loc) · 1.46 KB
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
43
44
45
46
#ifndef MAXSUBARRAY_H
#define MAXSUBARRAY_H
#include <iostream>
using namespace std;
constexpr static int INTEGER_MIN = -2147483647;
struct Data{
public:
int low, high, sum;
Data(int l, int h, int s);
};
/**
* This function performs basic tests of the functions.
*/
void testMaxSubarray();
/**
* This function finds the max subarray that crosses over the point mid and
* can reach as low as low and as high as high to find the maximum
* subarray with the largest sum.
*
* @param array[] the array that is being passed to find the data for.
* @param low the integer value that is the low point to which the function
* will work in.
* @param mid the mid point at which the array must include in order to find
* the max sum of the array that crosses the mid point.
* @param high the high point at which the array can go up to.
*/
Data findMaxCrossingSubarray(int array[], int low, int mid, int high);
/**
* This function finds the max subarray throughout the entire array array by
* finding what range of indexes give the highest sum without skipping
* any numbers between the low and high of the maximum subarray.
*
* @param array[] the array that is being passed to find the data for.
* @param low the integer value that is the low point to which the function
* will work in.
* @param high the high point at which the array can go up to.
*/
Data findMaxSubarray(int array[], int low, int high);
#endif /* MAXSUBARRAY_H */