For this assignment you will perform empirical analysis of the maximum subarray sum. Similar to the sample (longest incresing subsequence) you will be analyzing the output - what is the "maximum subarray sum", rather than the run-time of the algorithm. You have to: 1) run experiments on different problem sizes 2) draw graph 3) create LaTeX document a) intro - problem statement b) explain experiment setup c) graph. Approximate experimental graph with a mathematical function. Wikipedia: "Maximum subarray problem is the task of finding the contiguous subarray within a one-dimensional array of numbers which has the largest sum. For example, for the sequence of values -2, 1, -3, 4, -1, 2, 1, -5, 4; the contiguous subarray with the largest sum is 4, -1, 2, 1, with sum 6." More examples: -10 -1 2 -1 2 -1 2 -1 2 -10 -10 ================ -1 3 -1 3 -10 20 -30 ============= -1 3 -1 3 -10 2 -30 ====== I'm suggesting the following experiment setup: for a given size of array - say N 1) create array size N and initialize values [-N/4,3N/4] 2) randomly shuffle it See provided code. Generating pdf ============== You are required to use LaTeX. See LIS sample posted on the class website. ============================================= You may use this code to solve the problem: //to compile g++ -std=c++11 -O3 //to run my.exe 200 1000 //first argument us the number of tests, second array size #include #include #include #include #include int main( int argc, char** argv ) { int size = 0; std::sscanf(argv[1],"%i",&size); // problem size int num_tests = 0; std::sscanf(argv[2],"%i",&num_tests); // number of experiments // create array size n with values [-n/4,3n/4] !!!!!!!!!!!!!!!!!!!!!!!!! int *a = new int[ size ]; for (int i = 0; i < size; ++i) { a[i] = i - size/4; } // C++11 RNG std::random_device rd; std::mt19937 gen( rd() ); // random engine for ( int experiment =0; experiment < num_tests; ++experiment ) { std::shuffle( a, a+size, gen ); // C++11 // Kadane's algorithm starts here int max_so_far = a[0], max_ending_here = a[0]; for (int i = 0; i < size; ++i) { max_ending_here = max_ending_here + a[i]; if (max_so_far < max_ending_here) max_so_far = max_ending_here; if (max_ending_here < 0) max_ending_here = 0; } // Kadane's algorithm ends here std::cout << max_so_far << " "; // solution } delete [] a; }