There is a bug in this binarySearch. Find parameters that will not return the correct answer, and describe the fix to the bug.
1
public static int binarySearch(int[] arr, int target) {
2
int left = 0;
3
int right = arr.length - 1;
4
while (left <= right) {
5
int mid = (left + right) / 2; /* calculate midpoint */
6
if (arr[mid] < target) {
7
left = mid + 1;
7
}
9
if (arr[mid] > target) {
10
right = mid - 1;
11
}
12
else {
13
return mid;
14
}
15
}
16
return -1;
17
}