Rational Developer for System z
COBOL for Windows, Version 7.5, Programming Guide


Searching a table

COBOL provides two search techniques for tables: serial and binary.

To do serial searches, use SEARCH and indexing. For variable-length tables, you can use PERFORM with subscripting or indexing.

To do binary searches, use SEARCH ALL and indexing.

A binary search can be considerably more efficient than a serial search. For a serial search, the number of comparisons is of the order of n, the number of entries in the table. For a binary search, the number of comparisons is of the order of only the logarithm (base 2) of n. A binary search, however, requires that the table items already be sorted.

related tasks
Doing a serial search (SEARCH)
Doing a binary search (SEARCH ALL)


Terms of use | Feedback

Copyright IBM Corporation 1996, 2008.
This information center is powered by Eclipse technology. (http://www.eclipse.org)