Question: How to use the code I had to write Recursive Maximum Subarray in C++? --------------------------------------------------- // file : recursive.cpp #include using namespace std; //------------------------------------------------------ .
How to use the code I had to write Recursive Maximum Subarray in C++?
---------------------------------------------------
// file : recursive.cpp
#includeusing namespace std; //------------------------------------------------------ . . (insert helper function(s) here, if any.they should all be static.) . //------------------------------------------------------ void find_maximum_subarray(int A[], int N, int& bestStart, int& bestEnd, int& bestSum) { find_maximum_subarray(A, 0, N - 1, bestStart, bestEnd, bestSum); }
---------------------------------------------------
// file : main.cpp
#include
extern void find_maximum_subarray(int arr[], int l, int h);
int main(int argc, char* argv[]) {
int a[] = { 1, 2, 3, 4, 5 }; int n = sizeof(a) / sizeof(a[0]); int beststart = 0; int bestend = 0; int bestsum = 0;
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
