What is the difference between a binary search and a sequential search? What are the pertinent COBOL commands?

In a binary search the table element key values must be in ascending or descending sequence. The table is 'halved' 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 (ironically) the elements do not have to be in a specific sequence. The binary search is much faster for larger tables, while sequential works well with smaller ones. SEARCH ALL is used for binary searches; SEARCH for sequential.

Showing Answers 1 - 1 of 1 Answers

meetfred

  • Mar 5th, 2008
 

1. When we use sequential search in a COBOL  program it starts to search from t he
    begining of the table.

    COBOL Command:   SEARCH

2. When we use a Binary search in a COBOL  program it starts to  search by
    continually dividing the table into two halves untiall a match is found.
    
    COBOL Command:  SEARCH ALL

    This binary search is more efficient for tables larger than 70 items.

With regards,

Fredy

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions