Exercise 2.3-6

Exercise 2.3-6

Referring back to the searching problem (see Exercise 2.1-4), observe that if the subarray that is being searched is already sorted, the searching algorithm can check the midpoint of the subarray against and eliminate half of the subarray from further consideration. The binary search algorithm repeats this procedure having the size of the remaining portion of the subarray each time. Write pseudocode, either iterative or recursive for binary search. Argue that the worst-case running time of binary search is