Dirty-trick and below-the-belt question in real exam. binary search on unsorted array
Posted: Sat Mar 09, 2024 11:18 am
Code: Select all
// binary search on real exam
var array = List.of(1,3,2);
int i = Collections.binarySearch(array,3);
System.out.println(i);
However, the correct answer is '1' as binary search starts at the middle of the array where the correct value happens to be.