Complete the code to calculate the middle index in binary search.
mid := (low + [1]) / 2
The middle index is found by adding low and high indices and dividing by 2.
Complete the code to check if the middle element is the target.
if arr[mid] == [1] {
We compare the middle element with the target value we are searching for.
Fix the error in updating the low index when target is greater than middle element.
if arr[mid] < target { [1] = mid + 1 }
When target is greater, we move the low index to mid + 1 to search the right half.
Fill both blanks to update the high index when target is less than middle element.
if arr[mid] > target { [1] = [2] - 1 }
When target is less, we move high to mid - 1 to search the left half.
Fill all three blanks to complete the binary search loop condition and return statement.
for [1] <= [2] { mid := ([1] + [2]) / 2 if arr[mid] == target { return [3] } // other conditions }
The loop runs while low is less than or equal to high. mid is calculated using low and high.
