Complete the code to calculate the midpoint for dividing the array.
mid := (low + [1]) / 2
The midpoint is calculated by adding low and high indices and dividing by 2.
Complete the code to recursively call the divide and conquer function on the left half.
divideAndConquer(arr, low, [1])For the left half, the high index is mid - 1.
Fix the error in the base case condition to stop recursion when the segment is invalid.
if low [1] high { return }
The recursion stops when low is greater than high, meaning no elements to process.
Fill both blanks to complete the recurrence relation for merge sort time complexity.
T(n) = 2T([1]) + [2]n
Merge sort divides the problem into two halves of size n/2 and merges in linear time n.
Fill all three blanks to complete the recurrence relation for binary search time complexity.
T(n) = T([1]) + [2] + [3]
Binary search halves the problem size each time (n/2), does constant work (1), and no extra cost beyond that.
