Re: Linear search vs. Binary search

2013-05-01 Thread Anthony Rudd
The UPT instruction would appear to be ideal for implementing search. Unfortunately, although I found a mention to such a possible implementation in a SHARE presentation, it was only very theoretical and because the UPT example in the Principle of Operations is incomplete and I have not beein

Re: Linear search vs. Binary search

2013-05-01 Thread John Gilmore
The UPT (UPdate Tree) instruction inserts a new node in a tree conditionally. If it does not find an existing node having a nominated key in a [sub]tree, it inserts a new node into that [sub]tree at a location that, while not inappropriate, can be suboptimal. It is thus useful for maintaining a

UPT Instruction (Was: Linear search vs. Binary search)

2013-05-01 Thread Ed Jaffe
On 4/30/2013 11:37 PM, Anthony Rudd wrote: The UPT instruction would appear to be ideal for implementing search. Unfortunately, although I found a mention to such a possible implementation in a SHARE presentation, it was only very theoretical and because the UPT example in the Principle of

Re: UPT Instruction (Was: Linear search vs. Binary search)

2013-05-01 Thread John Gilmore
Sorting, yes indeed, conditional insertion is then the point; and when the sort is not a utility but an internal one it can be designed to work with UPT and its warts/characteristics/limitations. The usefulness of UPT for search operations is more problematic, but even for them something useful

Re: Linear search vs. Binary search

2013-05-01 Thread Paul Gilmartin
On Wed, 1 May 2013 07:51:50 -0400, John Gilmore wrote: The UPT (UPdate Tree) instruction inserts a new node in a tree conditionally. If it does not find an existing node having a nominated key in a [sub]tree, it inserts a new node into that [sub]tree at a location that, while not inappropriate,

UPT Instruction (Was: Linear search vs. Binary search)

2013-05-01 Thread Ed Jaffe
On 5/1/2013 7:41 AM, Paul Gilmartin wrote: Ah! We need UPTG. And the corresponding search function. And we need it to be serialized against concurrent updates (is it?) UPT is a modal instruction. Thus, no grande form is needed. In 24- and 31-bit mode, nodes are eight bytes in length and

Re: Linear search vs. Binary search (was: Assembler code)

2013-04-30 Thread Ed Jaffe
On 4/29/2013 10:10 PM, Paul Gilmartin wrote: I don't know how it keeps a 128-bit PSW. XSBOPSW16 DS XL16 16-BYTE PSW ANALOG OF RBOPSW -- Edward E Jaffe Phoenix Software International, Inc 831 Parkview Drive North El Segundo, CA 90245 http://www.phoenixsoftware.com/

Re: Linear search vs. Binary search

2013-04-30 Thread John Gilmore
David Crayson is right to point out that a decent compiler would have unrolled the loop in the specific five-element case he examines. This is not, however, a tactic that is appropriate for n 5. If one looks at what optimizing C compilers, the usual suspects, do with the classical

Re: Linear search vs. Binary search

2013-04-30 Thread Shmuel Metz (Seymour J.)
In m38v41wbsc@garlic.com, on 04/29/2013 at 12:18 PM, Anne Lynn Wheeler l...@garlic.com said: the claim has been made that 1/3rd of processor cycles for 370 instruction emulation went to checking for whether instruction already fetched/decoded in the pipeline has been modified. this

Re: Linear search vs. Binary search (was: Assembler code)

2013-04-30 Thread Shmuel Metz (Seymour J.)
In ofd1484f42.6be3b89a-on85257b5c.007e856a-85257b5c.007f3...@tsys.tss.net, on 04/29/2013 at 07:09 PM, Kirk Talman rkueb...@tsys.com said: I was given at one point the Assembler source of the fast Fourier transform, which I wanted to port to the 360. I had to read the 94 PoOp several times

Re: Linear search vs. Binary search

2013-04-30 Thread Anne Lynn Wheeler
shmuel+...@patriot.net (Shmuel Metz , Seymour J.) writes: It may be true for simulation of the S/370 on Intel, but a real 370/168 handled it in the I-unit. re: http://www.garlic.com/~lynn/2013f.html#65 Linear search vs. Binary search high-end machines were horizontal microcode with lots

Linear search vs. Binary search (was: Assembler code)

2013-04-29 Thread Paul Gilmartin
On Mon, 29 Apr 2013 10:50:25 -0400, John Gilmore wrote: It is not at all a bad subroutine. In many contexts the form of the second argument would be gratuitously clumsy, but this routine was (almost certainly) intended to be called from COBOL, and eight '0' or '1' characters is appropriate for

Re: Linear search vs. Binary search (was: Assembler code)

2013-04-29 Thread Kirk Talman
IBM Mainframe Discussion List IBM-MAIN@LISTSERV.UA.EDU wrote on 04/29/2013 11:06:34 AM: From: Paul Gilmartin paulgboul...@aim.com Has the z nowadays any memory protection mode that forbids fetching instructions from data storage? (Many other processors have such.) they have different

Re: Linear search vs. Binary search (was: Assembler code)

2013-04-29 Thread Joel C. Ewing
I would be surprised if a binary search could beat a linear search with only five items in the list, which is the case in the example code here. If usage of the function request codes were uniformly distributed, the average number of list item comparisons with five items for binary search

Re: Linear search vs. Binary search

2013-04-29 Thread Gerhard Postpischil
On 4/29/2013 1:56 PM, Ed Jaffe wrote: My ROT has always been to prefer linear search for single-digit quantities and prefer binary or hash algorithms for ten or more. A long time ago I implemented Knuth's balanced tree algorithm (AoP Vol. 3, sect 6.2) as a generalized subroutine, and

Re: Linear search vs. Binary search (was: Assembler code)

2013-04-29 Thread John Gilmore
I posted the formulæ for match-seeking binary and linear search in a 'related' thread. Following Knuth, the standard figure of merit for match-seeking binary search if the total number of ternary comparison operations required to search a set with 2n + 1 argments. For the n keys k(1) k(2) . .

Re: Linear search vs. Binary search

2013-04-29 Thread Paul Gilmartin
On Mon, 29 Apr 2013 13:16:59 -0400, John Gilmore wrote: The question which is faster depends in detail upon 1) whether binary search is implemented in assembly language, in which case ternary comparison operations are available, or in a statement-level language other that PL/I, in which case

Re: Linear search vs. Binary search (was: Assembler code)

2013-04-29 Thread Bernd Oppolzer
The subroutine that was originally posted didn't modify itself, but it constructed a little subroutine (one instruction and branch for return) in a working area which was provided as a parameter by the caller. So there is no reentrant problem and no flushing of the I-cache. Thank you for

Re: Linear search vs. Binary search (was: Assembler code)

2013-04-29 Thread Kirk Talman
IBM Mainframe Discussion List IBM-MAIN@LISTSERV.UA.EDU wrote on 04/29/2013 06:47:16 PM: From: Bernd Oppolzer bernd.oppol...@t-online.de Another story: I once had a hard time to understand a (very old) assembler module. It searched strings in another string, and the string to look for was

Re: Linear search vs. Binary search

2013-04-29 Thread David Crayford
On 30/04/2013 4:12 AM, Paul Gilmartin wrote: On Mon, 29 Apr 2013 13:16:59 -0400, John Gilmore wrote: The question which is faster depends in detail upon 1) whether binary search is implemented in assembly language, in which case ternary comparison operations are available, or in a