Question: Modify BinarySearch (Program 4.2.3) so that if the search key is in the array, it returns the smallest index (i) for which (a[i]) is equal
Modify BinarySearch (Program 4.2.3) so that if the search key is in the array, it returns the smallest index \(i\) for which \(a[i]\) is equal to key, and otherwise returns \(-i\), where \(i\) is the smallest index such that \(a[i]\) is greater than key.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
