Given a sorted array and an arbitrary number, write a program using binary search to determine if that number is a member of the array. Your program should read in an array, then keeps asking for a number, does the search, and displays the location in the array where the data can be found.
Binary search goes as follows.
Suppose we have n data items in ascending order. Let the first and the last one have subscripts Left and Right , respectively. Let the number to be searched for be Data . If Data is equal to element Middle , then Middle is the location where Data can be found and we are done. If Data is less than the data in location Middle , then all elements in the range of Middle and Right become irrelevant since they are all larger than Data , and can be eliminated from further consideration.