WADS 1993: Algorithms and Data Structures pp 27-34

# A generalization of binary search

• Richard M. Karp
Invited Presentations
Part of the Lecture Notes in Computer Science book series (LNCS, volume 709)

## Abstract

Let f be a nondecreasing integer-valued function whose domain is the set of integers [0., n]. The (n, m) problem is the problem of determining f at all points of its domain, given that f(0)=0 and f(n)=m. The paper [HM] determines the worst-case number of function evaluations needed to solve the (n, m) problem and gives one particular algorithm achieving the worst-case bound. We obtain the following further results concerning this problem:
• A family of deterministic algorithms that minimizes the worst-case number of function evaluations needed to solve the (n, m)-problem;

• A deterministic algorithm that comes within one step of minimizing the worst-case number of parallel steps required to solve the (n,m)-problem, where a given number p of concurrent function evaluations may be performed in each parallel step. This result requires that p ≤ m;

• A deterministic algorithm that minimizes the expected number of function evaluations when the function f is drawn from a probability distribution satisfying a natural symmetry property;

• A randomized algorithm that minimizes the worst-case expected number of function evaluations required to solve the (n, 1)-problem;

• Lower and upper bounds on the worst-case expected number of function evaluations required by a randomized algorithm to solve the (n, m)-problem for m > 1;

All the algorithms presented in the paper are extremely simple.

The (n, m) problem is equivalent to the following natural search problem: given a table consisting of n entries in increasing order, and given keys x1 < x2 < ... < xm, determine which of the given keys lie in the table. It is easily seen that the worst-case number of table entries that must be inspected in the search problem is equal to the worst-case number of function evaluations needed to solve the (n, m) problem.

## References

1. [GK]
C.R. Glassey and R.M. Karp, “On the Optimality of Huffman Trees,” SIAM J. Applied Math, Vol. 31, No. 2, pp. 368–378, September, 1976.
2. [HM]
R. Hassin and N. Megiddo, “An Optimal Algorithm for Finding All the Jumps of a Monotone Step-Function,” J. Algorithms, Vol. 6, No. 2, pp. 265–274, June, 1985.
3. [Yao]
A.C.C. Yao, “Probabilistic Computation: Towards a Unified Measure of Complexity,” Proc. 18th IEEE Symp. on Foundations of Computer Science, pp. 222–227, 1977.Google Scholar