Question: Hi, I need help with adding and changing a few lines that would return the start index and end index where the maximum subsequence sum

Hi, I need help with adding and changing a few lines that would return the start index and end index where the maximum subsequence sum is and explain how? Thank you! int alg3( int[] a, int left, int right ) { if( left == right ) // Base case return a[left]; int center = ( left + right ) / 2; int maxLeftSum = maxSumRec( a, left, center ); int maxRightSum = maxSumRec( a, center + 1, right ); int maxLeftBorderSum = 0, leftBorderSum = 0; for (int i = center; i >= left; i--) { leftBorderSum += a[i]; if (leftBorderSum > maxLeftBorderSum) { maxLeftBorderSum = leftBorderSum; } } int maxRightBorderSum = 0, rightBorderSum = 0; for (int j = center + 1; j <= right; j++) { rightBorderSum += a[j]; if (rightBorderSum > maxRightBorderSum) { maxRightBorderSum = rightBorderSum; } return alg3(maxLeftSum,maxRightSum,maxLeftBorderSum+maxRightBorderSum); }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!