COBOL Questions and Answers

What is the difference between a binary search and a sequential search?

In a binary search, the table element key values will be in ascending or descending sequence. The table is ‘halved'(Divided into two) to search for equal to, greater than or less than conditions until the element is found.

In a sequential search, the table is searched from top to bottom, so the elements do not have to be in a specific sequence.

The binary search is much faster for more tables, while sequential Search works well with lesser ones. SEARCH ALL is used for binary search; SEARCH for sequential search.