Which statement about Java's typical binary-search algorithm is TRUE?
- A
It fails with a runtime exception if the target is missing from the array.
- B
It runs in O(log n) time even on unsorted arrays as long as you use Integer.compare.
- Ccheck_circle
It requires the input array to be sorted; otherwise the result is undefined.
- D
Calling it on a duplicate-free unsorted array still works because the algorithm rechecks order.
Explanation
Binary search has a strict PRECONDITION: the array must be sorted. If the precondition is violated the result is undefined (it does not throw). When the target is missing, standard implementations return an "insertion-point" indicator like -(insert)-1, not an exception.