SEARCH AN ARRAY of ABSCISSAS
Given an array of abscissas A.J, J=1,...,N, with the elements either monotically increasing or monotically decreasing, and given a number V, find an integer J such that V lies between A.J and A.Jp1, where Jp1=J+1.
Bisection (see binary search) will find the right place in the table about lgN tries.
Unit: internal function
Global variables: ascending sequence of values A.1,...,A.N
Parameters: positive integer N, number V
Returns: a value J such that V is between A.J and A.Jp1, where Jp1=J+1. J=0 or J=N indicates that V is out of range.
Sequential search without sentinel
Search in associative arrays
Press W.H., Teukolsky S.A., Vetterling W.T., Flannery B.P. Numerical Recipes in C : the art of scientific computing
- 2nd ed. University Press, Cambridge, 1992