Algorithm Analysis
Understanding the problem
- Inputs: The end points, (lo, hi), of an ordered sequence
Answers to an series of questions
- Outputs: A selected item
- How the inputs are transformed to the outputs:
The questions of the series have the form
Is the desired item after item x?
so that the xth item is chosen to be midway in the interval
If the reply is yes, the new interval (next after x, hi)
If the reply is no, the new interval is (lo, x)
The output is the item when the interval contains only a single item