Re: Linear search vs binary

2013-10-29 Thread Bernd Oppolzer
I just would like to add that the program that I posted some days ago can be used to do non matching searches as well. In the not-found case the loop is left with R6 containing the index (and R7 the address) of the element that matches best (the element that has been compared in the last execution

Re: Linear search vs binary

2013-10-28 Thread Robert A. Rosenberg
At 07:20 -0500 on 10/28/2013, John Gilmore wrote about Re: Linear search vs binary: A greatest lower bound (GLB) on a search argument or a least upper bound (LUB) on it came be searched for in the same tables in which matches are sought. An example will help here. Suppose that we have a set

Re: Linear search vs binary

2013-10-28 Thread John Gilmore
There is one respect in which this thread on binary search has been unsatisfactory. It has concerned itself only with match-seeking binary search, and bounds-seeking binary search is at least as useful. A greatest lower bound (GLB) on a search argument or a least upper bound (LUB) on it came be

Re: Linear search vs binary

2013-10-26 Thread Bernd Oppolzer
BTW: the German mainframe Telefunken TR440 had a machine instruction which did a binary search on a sorted table of (48 bit) machine words; the instruction was called TLOG. Of course, there were other instructions for linear search, too. See page 17 of the instruction set reference (only availabl

Re: Linear search vs binary

2013-10-26 Thread Bernd Oppolzer
vector (in the worst case). At our shop, we have a macro which does this. No need to code the binary search yourself every time you need it. Kind regards Bernd Am 21.10.2013 22:49, schrieb Robert A. Rosenberg: At 06:27 -0700 on 10/21/2013, retired mainframer wrote about Re: Linear search vs b

Re: Linear search vs binary

2013-10-26 Thread Bernd Oppolzer
1.10.2013 22:49, schrieb Robert A. Rosenberg: At 06:27 -0700 on 10/21/2013, retired mainframer wrote about Re: Linear search vs binary: If your search target is uniformly distributed against the key, then on average a linear search will require 1750 iterations of your compare loop. A binary sear

Re: Linear search vs binary

2013-10-25 Thread Tony Harminc
On 25 October 2013 13:28, John Gilmore wrote: > Apart from its vulnerability to security-breaching abuses and the fact > that it must often be copied to be operated upon, another major defect > of ther nul-terminated string is that it may not contain a nul. > > I do not regard the nul-terminated s

Re: Linear search vs binary

2013-10-25 Thread Lloyd Fuller
> > From: Robert A. Rosenberg >To: ASSEMBLER-LIST@LISTSERV.UGA.EDU >Sent: Thursday, October 24, 2013 5:12 PM >Subject: Re: Linear search vs binary > > >At 12:45 -0400 on 10/24/2013, Tony Thigpen wrote about Re: Linear >search vs binary: > >>All entries wil

Re: Linear search vs binary

2013-10-25 Thread John Gilmore
Apart from its vulnerability to security-breaching abuses and the fact that it must often be copied to be operated upon, another major defect of ther nul-terminated string is that it may not contain a nul. I do not regard the nul-terminated string as a serious, i.e., non-frivolous data type. Oddl

Re: Linear search vs binary

2013-10-25 Thread Paul Gilmartin
On 2013-10-25, at 10:11, John Gilmore wrote: > > Moreover, nuls are unproblematic; they are invariant, the > same in ASCII, EBCDIC, . . . > Mostly true. But don't overlook the curse of the null-terminated string. -- gil

Automatic reply: Linear search vs binary

2013-10-25 Thread Duffin, Cormac
I will be out of the office on Monday and Tuesday the 28th & 29th of October, returning to work on Wednesday 30th. I will have no access to email / phone during this time. For all urgent project/maintenance related questions or issues, please send a mail to ANI - BOB-Visuals Support. For all ot

Re: Linear search vs binary

2013-10-25 Thread John Gilmore
As I made clear in an earlier post, it is my habit to pad out table elements with nuls, instances of x'00', to make all of their lengths equal. This operation is trivial in the macro language, but in response to some off-line questions I note that either of |&nulchar setc BYTE(x'00') or |&nulch

Re: Linear search vs binary

2013-10-25 Thread Tony Thigpen
robin Sent: Friday, October 25, 2013 7:13 AM To: MVS List Server 2 Subject: Re: Linear search vs binary From: "Tony Thigpen" Sent: Friday, October 25, 2013 10:05 PM Convert your PLX code to assembler and you will see that you are binary searching a pointer table that has fixed length ent

Re: Linear search vs binary

2013-10-25 Thread Blaicher, Christopher Y.
: Linear search vs binary From: "Tony Thigpen" Sent: Friday, October 25, 2013 10:05 PM > Convert your PLX code to assembler and you will see that you are > binary searching a pointer table that has fixed length entries. In PL/I , each string value (= each element of an array)

Re: Linear search vs binary

2013-10-25 Thread Tony Thigpen
As I don't know PL/I or PLX and this is the Assembler list, let's talk assembler. You stated that your code produced a binary search against a table where each row was variable length. I said binary search can't work on such a table. So, produce the code in assembler. Tony Thigpen -Origin

Re: Linear search vs binary

2013-10-25 Thread robin
From: "Tony Thigpen" Sent: Friday, October 25, 2013 10:05 PM Convert your PLX code to assembler and you will see that you are binary searching a pointer table that has fixed length entries. In PL/I , each string value (= each element of an array) occupies exactly the same storage.

Re: Linear search vs binary

2013-10-25 Thread Tony Thigpen
Convert your PLX code to assembler and you will see that you are binary searching a pointer table that has fixed length entries. Tony Thigpen -Original Message - From: robin Sent: 10/25/2013 04:52 AM From: "Tony Thigpen" Sent: Friday, October 25, 2013 12:16 PM > In XPL, each strin

Re: Linear search vs binary

2013-10-25 Thread robin
From: "Tony Thigpen" Sent: Friday, October 25, 2013 12:16 PM > In XPL, each string is accessed via descriptor that contains in a single > word > the memory address and the length. Your code is doing a binary search of the FIXED length POINTER table. No it's not. The code re-posted for you i

Re: Linear search vs binary

2013-10-24 Thread Tony Thigpen
> In XPL, each string is accessed via descriptor that contains in a single > word > the memory address and the length. Your code is doing a binary search of the FIXED length POINTER table. It is not doing a binary search of a table that has variable length rows. As I said, any table with variabl

Re: Linear search vs binary

2013-10-24 Thread robin
From: "Savor, Tom" Sent: Friday, October 25, 2013 11:40 AM Robin, InterestingI would have said the same thing (if asked), that you can't have binary search on variable length keys. Is your code posted C+ ?? I don't know it at all. The code is PL/I. How would you do this in Assembler

Re: Linear search vs binary

2013-10-24 Thread robin
From: "Tony Thigpen" Sent: Friday, October 25, 2013 11:35 AM Repost the code. Nothing I still have in my inbox shows code to perform a binary search of a table where each row occurrence can be any length. Array c has lower bound 0, upper bound n: i = -1; k = n+1; /* pointers that always poin

Re: Linear search vs binary

2013-10-24 Thread Tony Thigpen
Repost the code. Nothing I still have in my inbox shows code to perform a binary search of a table where each row occurrence can be any length. Tony Thigpen -Original Message - From: robin Sent: 10/24/2013 08:15 PM From: "Tony Thigpen" Sent: Friday, October 25, 2013 8:43 AM After

Re: Linear search vs binary

2013-10-24 Thread robin
From: "Tony Thigpen" Sent: Friday, October 25, 2013 9:14 AM > On 2013-10-24 11:29, Blaicher, Christopher Y. wrote: >> ... >> The second method used a binary chop of the data then scanned for the next entry. It was ugly, but it did its job. There are lots of limitations to it. >> > Somewhat e

Re: Linear search vs binary

2013-10-24 Thread robin
From: "Tony Thigpen" Sent: Friday, October 25, 2013 8:43 AM After a couple of posts about my post, I will go back to my point. You can only binary search a fixed length table. Nonsense. The table for the code that I posted previouisly consisted of varying-length strings. If you create an

Re: Linear search vs binary

2013-10-24 Thread robin
From: "Tony Thigpen" Sent: Friday, October 25, 2013 3:45 AM All entries will be fixed length. Can't really have variable length and use a binary search. :-) The code that I posted previously was for variable-length strings.

Re: Linear search vs binary

2013-10-24 Thread Dave Wade
Its been a while but bear with me and tell me if I am talking drivel... I guess on a modern machine its not a problem, but on an older environment with restricted memory and 4K page sizes then that is going to be around 10 pages. If the data is paged out and item you are looking for is in the firs

Re: Linear search vs binary

2013-10-24 Thread Tony Thigpen
> On 2013-10-24 11:29, Blaicher, Christopher Y. wrote: >> ... >> The second method used a binary chop of the data then scanned for the next entry. It was ugly, but it did its job. There are lots of limitations to it. >> > Somewhat elliptical. I assume he means that from any point > in the table

Re: Linear search vs binary

2013-10-24 Thread Alan Atkinson
data to be compared. But, > the pointer table is still a fixed length table. :-) > > You just can't binary search a variable length table. > > Tony Thigpen > > -Original Message - > From: Robert A. Rosenberg > Sent: 10/24/2013 05:12 PM >> At 12:45 -0400 o

Automatic reply: Linear search vs binary

2013-10-24 Thread Evans, James R. (RET-DAY)
I am out of the office until Monday 11/4/2013. I will read your note, as time permits, when I return to the office. If your e-mail is urgent and concerns a production issue/problem, please send your note to the 'GLO-RETS zOS Content' mailbox for attention. Thanks!

Re: Linear search vs binary

2013-10-24 Thread Paul Gilmartin
On 2013-10-24 15:51, John Gilmore wrote: > Tony writes that you just can't binary search a variable length table, > and this is certainly true if what he means is that you cannot search > a table the length of which changes while you are searching it. > > You can, however, search a table that varie

Re: Linear search vs binary

2013-10-24 Thread Tony Thigpen
By variable length, I was talking about each ROW being variable length. I.e, one row is 22 bytes, the next 10, the next 444. Nothing to do with the number of rows in a table changing. My original post stated: "All entries will be fixed length. Can't really have variable length and use a binary s

Re: Linear search vs binary

2013-10-24 Thread John Gilmore
Tony writes that you just can't binary search a variable length table, and this is certainly true if what he means is that you cannot search a table the length of which changes while you are searching it. You can, however, search a table that varies in length on different occasions. How not? Joh

Re: Linear search vs binary

2013-10-24 Thread Tony Thigpen
/2013, Tony Thigpen wrote about Re: Linear search vs binary: All entries will be fixed length. Can't really have variable length and use a binary search. That depends. If the table you are sorting is a table of pointers to the actual data (and is ordered by the compare field), the entries can b

Re: Linear search vs binary

2013-10-24 Thread Robert A. Rosenberg
At 13:52 +0200 on 10/24/2013, Rob van der Heij wrote about Re: Linear search vs binary: On 24 October 2013 12:50, Don Higgins wrote: I see discussion about optimizing the binary search, but I don't see any discussion about optimizing linear search which might make it much faster

Re: Linear search vs binary

2013-10-24 Thread Robert A. Rosenberg
At 12:45 -0400 on 10/24/2013, Tony Thigpen wrote about Re: Linear search vs binary: All entries will be fixed length. Can't really have variable length and use a binary search. That depends. If the table you are sorting is a table of pointers to the actual data (and is ordered by the co

Re: Linear search vs binary

2013-10-24 Thread Blaicher, Christopher Y.
P: 201-930-8260 | M: 512-627-3803 E: cblaic...@syncsort.com -Original Message- From: IBM Mainframe Assembler List [mailto:ASSEMBLER-LIST@LISTSERV.UGA.EDU] On Behalf Of Tony Thigpen Sent: Thursday, October 24, 2013 11:46 AM To: MVS List Server 2 Subject: Re: Linear search vs binary All

Re: Linear search vs binary

2013-10-24 Thread Tony Thigpen
I was thinking something more generic. The table description and layout is outside the code. The code would be a generic branch and return routine. How the table is loaded is also not part of the code. It could be done at assemble time or at run time by reading a file. Correctness of data is the

Re: Linear search vs binary

2013-10-24 Thread John Gilmore
Tony, The code you want must address a number of additional issues. Are the elements to be assembled into the table all of the same length? If not, they must be padded with nuls, x'00', and not blanks, x'40'|x'20', at table-assembly time to make them so. Is the search argument shorter than the

Re: Linear search vs binary

2013-10-24 Thread Tony Thigpen
Now, I would like to see REAL assembler code for a binary search that takes into consideration all the items being discussed and works for a varying length tables, including an odd number of rows in the table. To make it simple, assume: R2 = @ first entry R3 = @ last entry R4 = length of each entr

Re: Linear search vs binary

2013-10-24 Thread John Gilmore
Knuth's analysis of match-seeking binary search deals in an ordered set of n keys {k(1) < k(2) < . . . < k(i) < . . . k(n)} and another set of 2n + 1 searches, viz., o one such that s < k(1), which fails, o n - 1 such that k(i) < s < k(i+1), i = 1, 2, . . . , n - 1, all of which fail, o n

Re: Linear search vs binary

2013-10-24 Thread Rob van der Heij
On 24 October 2013 12:50, Don Higgins wrote: > I see discussion about optimizing the binary search, but I don't see any > discussion about optimizing linear search which might make it much faster > than binary depending on the search history. Putting the last key found at > front of most recentl

Re: Linear search vs binary

2013-10-24 Thread Don Higgins
All I see discussion about optimizing the binary search, but I don't see any discussion about optimizing linear search which might make it much faster than binary depending on the search history. Putting the last key found at front of most recently used list or just holding last found as a firs

Re: Linear search vs binary

2013-10-23 Thread Rob van der Heij
On 24 October 2013 02:43, Paul Gilmartin wrote: > > The search may be terminated early (however infrequently) on > discovering an exact match. But this requires an extra comparison > if ternary results are unavailable (as they are in assembler -- > is that sufficiently on-topic?) The cost of th

Re: Linear search vs binary

2013-10-23 Thread Paul Gilmartin
On 2013-10-23 17:51, robin wrote: >>> >> ... the value of comparison operands [operators -- gil] having >> a ternary result. Of course this is available in (zSeries) >> assembler. It might typically shorten a table search by one >> iteration. > > How is that? > The search may be terminated early

Re: Linear search vs binary

2013-10-23 Thread Alan Atkinson
Glad you got some use out of it. It's a pretty simplistic implementation, but sufficient for our needs. Although based on how rapidly the discussion veered into other languages I thought I'd missed your point somehow. Sent from my iPad > On Oct 23, 2013, at 9:43 AM, "Dougie Lawson" wrote: >

Re: Linear search vs binary

2013-10-23 Thread robin
From: "Paul Gilmartin" Sent: Tuesday, October 22, 2013 1:42 AM On 2013-10-21, at 07:13, John Gilmore wrote: Perhaps also worth noting explicitly is that the linear-search scheme done well is not significantly less complex than the binary-search one. You've earlier advocated the value of com

Re: Linear search vs binary

2013-10-23 Thread Dougie Lawson
Hi Alan, I found some test data. I found a ready written IMS macro to sort my test data (which was a real bonus). And I got your code sample to run and get the right answer. Thank you - I owe you a virtual beer. To all the other correspondents - thank you - a simple request has generated some

Re: Linear search vs binary

2013-10-23 Thread robin
From: "Dougie Lawson" Sent: Monday, October 21, 2013 10:32 PM If I have a table of 3,500 entries of twelve bytes (I'm doing a compare of eight bytes to find the entry I'm looking for and a check on a half word marker for the end of the table to avoid running off the end) then is it worth the p

Re: signum (was: Linear search vs binary)

2013-10-23 Thread Rob van der Heij
I understand. I don't even need a computer to do that :-) The "return" was just to discourage the optimizer to throw away all the code because I didn't use the result. The thing that kept me awake briefly was whether the optimizer would recognize that the shortcut and code a single compare with tw

Re: signum (was: Linear search vs binary)

2013-10-23 Thread John Gilmore
Rob, Interestingly, when I take your C example, if ( j < k ) m = -1; else if (j > k) m = 1; else m = 0; return m; and rewrite it trivially modified in PL/I as if j < k then m = -1; else if j > k then m = 1; else m = 0; return (m); I cannot reproduce your results. John Gilmor

Re: signum (was: Linear search vs binary)

2013-10-23 Thread robin
From: "Rob van der Heij" Sent: Wednesday, October 23, 2013 8:12 PM Since the machine architectures that came to mind all have this 3-state result after comparison, I expected the compiler to take advantage of it when I write something like if ( j < k ) m = -1; else if (j > k) m = 1; else m

Re: signum (was: Linear search vs binary)

2013-10-23 Thread Rob van der Heij
Since the machine architectures that came to mind all have this 3-state result after comparison, I expected the compiler to take advantage of it when I write something like if ( j < k ) m = -1; else if (j > k) m = 1; else m = 0; return m; A few surprises with gcc, like pretty dumb code wit

Re: signum (was: Linear search vs binary)

2013-10-23 Thread robin
From: "John Gilmore" Sent: Tuesday, October 22, 2013 9:31 AM PL/I was robbed of FIXEDOVERFLOW for binary fixed values. Use SIZE instead. It is still available for PL/I decimal fixed, i.e., packed decimal values. The LE does in fact make a facility available for executing what is in efff

Re: signum (was: Linear search vs binary)

2013-10-21 Thread John Gilmore
PL/I was robbed of FIXEDOVERFLOW for binary fixed values. It is still available for PL/I decimal fixed, i.e., packed decimal values. The LE does in fact make a facility available for executing what is in efffect an arbitrary SPM instruction; but it is documented so poorly---It has been all but h

signum (was: Linear search vs binary)

2013-10-21 Thread Paul Gilmartin
On 2013-10-21 11:06, John Gilmore wrote: > > [signum] is available as a BIF called sign in PL/I, where it is [almost > always] > implemented in line. An analogous function is available for strings > in C, where it is implemented as a library subroutine. It has always > been available in FORTRAN

Hardware or Compiler Design? (was: Linear search vs binary)

2013-10-21 Thread Paul Gilmartin
On 2013-10-21 14:35, Gainsford, Allen wrote: >> It is known, was indeed emphasized by Backus, is that he was much >> concerned not to deprive 704 assembly-language programmers of >> facilities they prized. His situation was very different from >> ours today. He wanted to open up programming to ot

Re: Linear search vs binary

2013-10-21 Thread Robert A. Rosenberg
At 06:27 -0700 on 10/21/2013, retired mainframer wrote about Re: Linear search vs binary: If your search target is uniformly distributed against the key, then on average a linear search will require 1750 iterations of your compare loop. A binary search will require a constant 12 iterations

Re: Linear search vs binary

2013-10-21 Thread Gainsford, Allen
> It is known, was indeed emphasized by Backus, is that he was much > concerned not to deprive 704 assembly-language programmers of > facilities they prized. His situation was very different from > ours today. He wanted to open up programming to others, but he > crucially needed to convince 704 a

Re: Linear search vs binary

2013-10-21 Thread John Gilmore
John McCarthy, who for a time used CAS---as well as CAR and CADDR, which survived---in LISP, thought that the instruction came first, i.e., that the instruction was the model for the arithmetic-IF statement. It is my guess that he was right, but it may now be too late to resolve this particular ch

Re: Linear search vs binary

2013-10-21 Thread Gerhard Postpischil
On 10/21/2013 1:06 PM, John Gilmore wrote: It has always been available in FORTRAN in the form of the much deprecated but in fact enormously useful arithmetic-IF statement Which brings up the question of whether the trinary compare results (e.g., CAS [C

Re: Linear search vs binary

2013-10-21 Thread Alan Atkinson
:29 PM To: ASSEMBLER-LIST@LISTSERV.UGA.EDU Subject: Re: Linear search vs binary On 21 October 2013 13:34, Alan Atkinson wrote: > > MHRF,ISKEYLN4 > Hi Alan, Thanks for the code sample. I wasn't sure what value that ISKEYLN4 half word should hold. I found a really neat

Re: Linear search vs binary

2013-10-21 Thread Dougie Lawson
On 21 October 2013 13:34, Alan Atkinson wrote: > > MHRF,ISKEYLN4 > Hi Alan, Thanks for the code sample. I wasn't sure what value that ISKEYLN4 half word should hold. I found a really neat macro as part of IMS (member IMSORT in IMS.SDFSMAC) which means I can easily build a static t

Re: Linear search vs binary

2013-10-21 Thread John Gilmore
The arithmetic function that mathematicians call signum, viz., for an arithmetic expression x signum(x) = -1, a < 0, signum(x) = 0, a = 0, signum(x) = +1, a > 0 is available as a BIF called sign in PL/I, where it is [almost always] implemented in line. An analogous function is available for st

Re: Linear search vs binary

2013-10-21 Thread Paul Gilmartin
> - Original Message - > > From: "Dougie Lawson" > To: ASSEMBLER-LIST@LISTSERV.UGA.EDU > Sent: Monday, October 21, 2013 6:32:15 AM > Subject: Linear search vs binary > > If I have a table of 3,500 entries of twelve bytes (I'm doing a compare of >

Re: Linear search vs binary

2013-10-21 Thread DASDBILL2
words, ID. [1[   Bill Fairchild Franklin, TN   [1] It Depends. - Original Message - From: "Dougie Lawson" To: ASSEMBLER-LIST@LISTSERV.UGA.EDU Sent: Monday, October 21, 2013 6:32:15 AM Subject: Linear search vs binary If I have a table of 3,500 entries of twelve bytes

Re: Linear search vs binary

2013-10-21 Thread Paul Gilmartin
On 2013-10-21, at 07:13, John Gilmore wrote: > Perhaps also worth noting explicitly is that the linear-search scheme > done well is not significantly less complex than the binary-search > one. > You've earlier advocated the value of comparison operands having a ternary result. Of course this is a

Re: Linear search vs binary

2013-10-21 Thread retired mainframer
m: IBM Mainframe Assembler List [mailto:ASSEMBLER- :>: l...@listserv.uga.edu] On Behalf Of Dougie Lawson :>: Sent: Monday, October 21, 2013 4:32 AM :>: To: ASSEMBLER-LIST@LISTSERV.UGA.EDU :>: Subject: Linear search vs binary :>: :>: If I have a table of 3,500 entries of twelve by

Re: Linear search vs binary

2013-10-21 Thread John Gilmore
Perhaps also worth noting explicitly is that the linear-search scheme done well is not significantly less complex than the binary-search one. John Gilmore, Ashland, MA 01721 - USA

Re: Linear search vs binary

2013-10-21 Thread John Gilmore
For match-seeking binary search Knuth's classical figure of merit for an ordered table of n elements is M(n) = 2[(n + 1)q + 2e] – n in which q = floor[log2(n + 1)] and e = n - (2**q - 1). Here q = 11, e = 3500 - 2047 = 1453, and thus M(3500) = 2[3501 x 11 + 2 x 1453] - 3500 = 78324 For linear

Re: Linear search vs binary

2013-10-21 Thread Alan Atkinson
LIST@LISTSERV.UGA.EDU] On Behalf Of Alan Atkinson Sent: Monday, October 21, 2013 8:35 AM To: ASSEMBLER-LIST@LISTSERV.UGA.EDU Subject: Re: Linear search vs binary Leaving aside hashing and suchlike, we've used this for a while in multiple places. It's a ripoff of the C binsrch algorithm in

Re: Linear search vs binary

2013-10-21 Thread Paul Raulerson
Guys- doesn't that depend - a lot - on how often the code is actually executed? A couple billion times a day makes it a no-brainer to do a binary search, a couple thousand times per day, perhaps just the opposite. Paul Typos courtesy of my iPhone and my fat fingers! > On Oct 21, 2013, at 7:38

Re: Linear search vs binary

2013-10-21 Thread Alan Atkinson
CH'0' * BSMTCH CLC 0(0,R4),0(RF) COMPARE REQUESTED KEY WITH RECORD * BSXITSTRF,FULL -Original Message- From: IBM Mainframe Assembler List [mailto:ASSEMBLER-LIST@LISTSERV.UGA.EDU] On Behalf Of Rob van der Heij Sent: Monday, October 21, 2013 7

Re: Linear search vs binary

2013-10-21 Thread Martin Truebner
As Rob has already said- YES it is worth it I say that too- worth it- here is my point. assumptions: 1.) every instr is one unit (yes I know this is pretty simple but ...) 2.) random access pattern so here we go a simple search is n instructions- a binary search is +x instructions for a

Re: Linear search vs binary

2013-10-21 Thread Bodoh John Robert [Contractor]
I would use a hash table. It's much faster. John -Original Message- From: IBM Mainframe Assembler List [mailto:ASSEMBLER-LIST@listserv.uga.edu] On Behalf Of Dougie Lawson Sent: Monday, October 21, 2013 7:32 AM To: ASSEMBLER-LIST@listserv.uga.edu Subject: Linear search vs binary

Re: Linear search vs binary

2013-10-21 Thread Rob van der Heij
If you want to make it 4096 entries, you could step through the table with binary search very cheap by shifting a mask on each pass. I would already think about it with 35 entries... ;-) On 21 October 2013 13:32, Dougie Lawson wrote: > If I have a table of 3,500 entries of twelve bytes (I'm doi

Linear search vs binary

2013-10-21 Thread Dougie Lawson
If I have a table of 3,500 entries of twelve bytes (I'm doing a compare of eight bytes to find the entry I'm looking for and a check on a half word marker for the end of the table to avoid running off the end) then is it worth the pain of re-writing it as a binary search. If it is worth the pain a