Re: Cobol Linear search Vs Perfrom Until

From: Richard (riplin_at_Azonic.co.nz)
Date: 07/18/04


Date: 17 Jul 2004 16:51:47 -0700

Glenn Someone <dontspamme@whydoyouneedmyaddressspammers.com> wrote

> Is that the assumption? Because it's something you've never seen, you
> assume it would blow up and not work.

The problem is not that it will 'blow up and not work', the problem is
that the results are not defined and may be different in the next
version, or from some other change.

> Have you ever heard of good sound testing?

Testing only provides results in the environments tested. If the
environment changes then undefined results may change.

> Like I said study what the binary search does (if
> SEARCH ALL doesn't cut it, provide a binary search, it's not that hard
> to code yourself!), and then you might get a little bit of ease out of
> it.

But that is not necessary. Adding a sequence is trivial, either at the
time the table is created or by a single serial pass to do this.
 
> >(row 1) AAA 0
> >(row 2) AAA 1
> >(row 3) BBB 0
> >(row 4) BBB 1
> >(row 5) BBB 2
> >(row 6) CCC 0
> >(row 7) CCC 1

> No. This is showing you don't have a conception of what a binary
> search is. Searching for BBB will return row 4 from a properly coded
> binary search, AAA row 2, CCC row 6. Then finding the first entry
> involves your sequential search option (using PERFORM UNTIL). I
> wouldn't personally go up and down from the spot discovered, because
> of that simplicity argument (I'd go find the first one and then
> process all records accordingly).

Adding the sequence and then SEARCH ALL '<key> 0' gives a reliable,
portable, _defined_ result of the first entry for <key> without having
to do your own search coding, or grubby -1, +1 shuffling.



Relevant Pages

  • a simpler way...?
    ... I need to have a field in an MRO number entries in sequence. ... the first entry gets a "1" and the second gets a ...
    (comp.databases.paradox)
  • Re: Compile Error
    ... sequence of numbers, pick one, put it in the text box and count it out as the ... first entry is made. ... NEC 2008 ... "Lord Kelvan" wrote: ...
    (microsoft.public.access.formscoding)
  • Re: In the news: Researchers Predict Infinite Genomes
    ... >> Glenn wrote: ... > Sequence one ... (Hint: Do bacteria interbreed?) ... > however fire an infinite number of questions back at you, ...
    (talk.origins)
  • Re: Algorithm to find break in contiguity
    ... save any significant time by jumping around doing a binary search, ... the missing number hasn't been reached yet) as you are reading. ... If the data is not already in sequence, ... Since you used the word "contiguity" in the Subject field, ...
    (comp.programming)
  • Re: Finding a maxima with binary search?
    ... >> decreasing integers, then the first difference tells which way. ... Try the sequence: ... I suspect you could modify the basic approach of a binary search ...
    (comp.programming)