Question: ( Binary Search Deluxe ) When binary searching a sorted array that contains more than one key equal to the search key, the client may

(Binary Search Deluxe) When binary searching a sorted array that contains more than one key equal to the search key, the client may want to know the index of either the first or the last such key. Accordingly, implement a library called BinarySearchDeluxe with the following API:
Corner Cases
Each method should throw a NullPointerException("a, key, or c is null") if any of the arguments is null. You may assume that the array a is sorted (with respect to the comparator c).
Performance Requirements
Each method should should run in time T (n) log n, where n is the length of the array a. 2 BinarySearchDeluxe
static int firstIndexOf(Key[] a, Key key, Comparator c) returns the index of the first key in a that equals the search key, or -1, according to the order induced by the comparator c static int lastIndexOf(Key[] a, Key key, Comparator c) returns the index of the last key in a that equals the search key, or -1, according to the order induced by the comparator c

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!