This is the code:
public class Main {
public static Scanner scanner = new Scanner(System.in);
public static void main(String[] args) throws IOException {
int arr[] = {10,50,999,1000};
int index = Arrays.binarySearch(arr,55);
System.out.println(index);
}
}
The output here is '-3', if the output from this formula "(-(insertion point) - 1)" that means the insertion point is '4' and that is not right.
So what i am missing?
(-2-1) = -3, so the value SHOULD be at index 2, after the 10 and the 50