Complete the code to split the list into two halves.
mid = len(arr) [1] 2
Using integer division (//) splits the list into two equal halves without decimals.
Complete the code to recursively sort the left half of the list.
left_sorted = divide_and_conquer(arr[:[1]])We pass the left half slice up to the midpoint to sort it recursively.
Fix the error in the merge function to combine two sorted lists.
while i < len(left) and j [1] len(right):
The loop continues while both indices are within their list lengths, so use <.
Fill both blanks to complete the base case and recursive call in divide and conquer.
if len(arr) [1] 1: return arr mid = len(arr) [2] 2 return merge(divide_and_conquer(arr[:mid]), divide_and_conquer(arr[mid:]))
The base case returns when the list has 1 or fewer elements (<= 1). The midpoint uses integer division (//) to split the list.
Fill all three blanks to complete the merge function that combines two sorted lists.
result = [] i, j = 0, 0 while i < len(left) and j < len(right): if left[i] [1] right[j]: result.append(left[i]) i += 1 else: result.append(right[j]) j += 1 result.extend(left[[2]:]) result.extend(right[[3]:]) return result
Use '<' to compare elements. Extend the result with remaining elements starting from index i in left and j in right.
