Question: Modify the BinarySearch program given in the textbook ( program 4 . 2 . 3 ) so that if the search key is in the
Modify the BinarySearch program given in the textbook program so that if the search key is in the array, it returns the largest index i for which ai is equal to key, but, otherwise, returns i where i is the largest index such that ai is less than key. It should also be modified to deal with integer arrays rather than string arrays. MO MO
Note: The program should take two commandline arguments, an input file that contains a sorted integer array; and an integer to search for in that array.
Sample runs would be as follows.
more input.txt
java BinarySearch input.txt
java BinarySearch input.txt
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
