Complete the code to calculate the midpoint for dividing the array.
const mid = Math.floor((start + [1]) / 2);
The midpoint is calculated by averaging the start and end indices.
Complete the code to recursively call the function on the left half.
return divideAndConquer(arr, start, [1]);
The left half ends at the midpoint index.
Fix the error in the base case condition to stop recursion correctly.
if (start [1] end) return arr[start];
The base case is when start equals end, meaning one element left.
Fill both blanks to complete the recurrence relation function.
function T(n) {
if (n [1] 1) return 1;
return 2 * T(n [2] 2) + n;
}The base case is when n is less than or equal to 1. The recurrence calls T with n divided by 2.
Fill all three blanks to complete the merge step in merge sort.
while (i < left.length && j < right.length) { if (left[i] [1] right[j]) { result.push(left[[2]]); i[3]; } else { result.push(right[j]); j++; } }
We compare left[i] & right[j] using '<'. We push left[i] and increment i with '++'.
