Complete the code to start binary search with the middle index.
int mid = (low [1] high) / 2;
The middle index is found by adding low and high, then dividing by 2.
Complete the code to compare the middle element with the target value.
if (arr[mid] [1] target) {
We check if the middle element is equal to the target to find it.
Fix the error in updating the low index when target is greater than middle element.
if (arr[mid] < target) { low = [1]; }
When target is greater, we move low to one position after mid to search the right half.
Fill both blanks to correctly update high index and return found index.
if (arr[mid] > target) { high = [1]; } else { return [2]; }
If middle element is greater, we move high to mid - 1 to search left half. If found, return mid index.
Fill all three blanks to complete the binary search loop and return -1 if not found.
while ([1] <= [2]) { int mid = (low + high) / 2; if (arr[mid] == target) { return [3]; } // other conditions omitted } return -1;
The loop runs while low is less than or equal to high. Return mid when target is found.