In the implementation, it didn’t check mid +1 is < arr.length-1; how could it make sure mid+1 is not out of Bounds? Thanks.
public static int findMax(int[] arr) {
int start = 0, end = arr.length - 1;
while (start < end) {
int mid = start + (end - start) / 2;
if (arr[mid] > arr[mid + 1]) {
end = mid;
} else {
start = mid + 1;
}
}