why doesn’t my binary search method return -1 when it the target number doesn’t appear in the array? It goes into a loop
public static int binarySearch(int[] x, int target) { int left = 0; int right = x.length – 1; int mid = (right + left ) / 2; while ( left <= right) { mid = (right + left) / 2; if (x[mid] == target) { return mid; } else if (x[mid] > target) { right […]