Duplicates in Binary Search in COBOL.

OS/VS COBOL, COBOL II, Enterprise COBOL for z/OS. OpenCOBOL and OOCobol.
Post Reply
Kailash
Registered Member
Posts: 10
Joined: Thu Nov 21, 2013 11:53 pm

Duplicates in Binary Search in COBOL.

Post by Kailash »

Hi,

While working with Binary Search I have understood that Duplicates in Binary Search in COBOL are not allowed. Could someone tell me the reason behind this? Why duplicates are not allowed?
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1886
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Duplicates in Binary Search in COBOL.

Post by Robert Sample »

I think you misunderstand -- it is not that they are not allowed. It is very possible to generate a table with duplicate key values and use that table in a SEARCH ALL statement. What IBM tells you is that, if the keys are not ascending (or descending, depending upon the coding) -- and duplicate keys are definitely not ascending (nor descending) -- then you CANNOT be assured that the SEARCH ALL worked. It may return a wrong record, or it may fail to return a record even though the key is in the table.
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “IBM COBOL, GnuCOBOL (OpenCOBOL), OOCobol.”