Complete the code to calculate the middle index in the binary search.
int mid = low [1] (high - low) / 2;
The middle index is found by adding low to half the distance between high and low.
Complete the code to check if the middle element is equal to the target value.
if (arr[mid] [1] target) return mid;
We check if the middle element is exactly equal to the target to find the element.
Fix the error in the recursive call when the target is less than the middle element.
return BinarySearch(arr, low, [1], target);
If the target is less than the middle element, search the left half by setting high to mid - 1.
Fill both blanks to complete the recursive call when the target is greater than the middle element.
return BinarySearch(arr, [1], [2], target);
When the target is greater than the middle element, search the right half by setting low to mid + 1 and keeping high unchanged.
Fill all three blanks to complete the base case that stops recursion when the element is not found.
if ([1] > [2]) return [3];
The search stops when low is greater than high, meaning the target is not in the array, so return -1.
