Question: Bentley [ Ben 0 0 , Chap. 4 ] provides the following informal description of binary search: Bentley [ Ben 0 0 , Chap. 4
Bentley Ben Chap. provides the following informal description of binary search:
Bentley Ben Chap. provides the following informal description of binary search:
We are to determine whether the sorted array XN contains the element T Binary search solves the problem by keeping track of a range within the array in which T must be if it is anywhere in the array. Initially, the range is the entire array. The range is shrunk by comparing its middle element to T and discarding half the range. The process continues until T is discovered in the array or until the range in which it must lie is known to be empty.
Write code for binary search in your favorite imperative programming language. What loop constructs did you find to be most useful? NB: when he asked more than a hundred professional programmers to solve this problem, Bentley found that only about got it right the first time, without testing.
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
