|
SEARCH AN ARRAY of ABSCISSAS PROBLEM
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.
ALGORITHM
Bisection (see binary search) will find the right place in the table about lgN tries.
IMPLEMENTATION
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.
CONNECTIONS
Binary search
Sequential search Sequential search without sentinel Interpolation search Search in associative arrays
Literature
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
|
|
|
|
|
|
![]()