Complete the code to find the middle index of the array segment.
let 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 three values.
return [1](left_sum, right_sum, cross_sum);
We want the maximum sum among left, right, and crossing subarrays.
Fix the error in the loop to find the maximum crossing subarray sum on the left side.
for i in ([1]..=mid).rev() { sum += arr[i]; if sum > left_sum { left_sum = sum; } }
The loop goes from mid down to low index to find max sum on left side.
Fill both blanks to find the maximum crossing subarray sum on the right side.
sum = 0; for j in (mid + 1)..=[1] { sum += arr[j]; if sum > [2] { right_sum = sum; } }
The loop goes from mid+1 to high to find max sum on right side. We compare sum with right_sum.
Fill all four blanks to complete the recursive divide and conquer function call.
let left_sum = find_max_subarray(arr, [1], mid); let right_sum = find_max_subarray(arr, mid + 1, [2]); let cross_sum = find_max_crossing_subarray(arr, [3], mid, [4]);
Recursive calls use low to mid, mid+1 to high, and crossing uses low, mid, high.
