Complete the code to declare the merge function prototype.
void [1](int arr[], int l, int m, int r);The function that merges two halves is named merge.
Complete the code to calculate the middle index for splitting the array.
int m = (l [1] r) / 2;
The middle index is calculated by adding left and right indices and dividing by 2.
Fix the error in the merge function call to correctly merge two halves.
merge(arr, l, m, [1]);The last parameter should be the right index r to merge the two halves correctly.
Fill both blanks to complete the recursive calls for merge sort.
mergeSort(arr, [1], m); mergeSort(arr, m [2] 1, r);
The first call sorts from left to middle, the second from middle+1 to right, so the second blank is plus.
Fill all three blanks to complete the merge function's main loop conditions.
while (i [1] n1 && j [2] n2) { if (L[i] [3] R[j]) { arr[k] = L[i]; i++; } else { arr[k] = R[j]; j++; } k++; }
The loop continues while both i and j are less than their array sizes. The if condition compares L[i] <= R[j] to pick the smaller element.
