I've always taken for granted that SEARCH ALL (binary search) takes at most O(log N) comparisons to locate an entry in a table. However, I've never delved into the specifics of any implementation in COBOL. I'm reviewing some COBOL material where the author states that to do a SEARCH ALL on a table of say 3900 entries requires between 10 and 14 comparisons.
I suspect each "probe" of the table requires maybe three comparisons (are we done yet?; Key = item; Key < (or >) item). Only two of these are key comparisons. I think, therefore, that the right "answer" is 24 key comparisons (2^12 = 4096).
Do any of you have insight on this topic, especially on specific platforms (e.g. IBM COBOL II)?
Regards.
Glenn
I suspect each "probe" of the table requires maybe three comparisons (are we done yet?; Key = item; Key < (or >) item). Only two of these are key comparisons. I think, therefore, that the right "answer" is 24 key comparisons (2^12 = 4096).
Do any of you have insight on this topic, especially on specific platforms (e.g. IBM COBOL II)?
Regards.
Glenn