Complete the code to find the middle index of the array segment.
int mid = (low + [1]) / 2;
The middle index is calculated by adding low and high indices and dividing by 2.
Complete the code to return the maximum of two integers.
int max = (a > [1]) ? a : b;We compare a and b, returning the greater value.
Fix the error in the loop that finds maximum crossing subarray sum.
for (int i = mid; i >= [1]; i--) { sum += arr[i]; if (sum > left_sum) left_sum = sum; }
The loop should run from mid down to low index to cover left half.
Fill both blanks to correctly compute the maximum crossing subarray sum.
int right_sum = INT_MIN; int sum = 0; for (int j = mid + 1; j <= [1]; j++) { sum += arr[j]; if (sum > [2]) right_sum = sum; }
The loop runs from mid+1 to high. We compare sum with right_sum to update it.
Fill all three blanks to return the maximum subarray sum among left, right, and crossing sums.
return [1](left_sum, [2](right_sum, [3]));
We use max function twice to find the maximum among three sums.
