A colleague you work with is tired of people calling binary…
A colleague you work with is tired of people calling binary search on unsorted arrays (they keep reporting getting back incorrect answers). They propose the following defensive variant: public int defensiveBinarySearch(int[] array , int key) { Collections.sort(array); // ensure the input list is sorted return binarySearch(array, key); // run normal binary search } What is the Big O runtime of your colleague’s defensive version?