search

Clifford C. Skolnick cliffs at sunrock.east.sun.com
Sat Aug 19 09:15:42 AEST 1989


In article <184 at stsim.UUCP> glenn at stsim.UUCP (Glenn Ford) writes:

   I am writing a small project (not related to work, personal) that has to
   do search's on a sorted database.  I search off the keyword which is string
   of N length and is unique to all other keys.  For right now I do a binary
   search off the database, but this tends to be slow when run off a floppy
   drive (yes, it has to run on a floppy drive in SOME cases).  My question
   is: Is there a faster, yet fairly easy to implement, routine that can
   search my database?  Faster than binary search..  I don't want B-Tree's.  My
   database is allready built.

   Glenn Ford
   ..uunet!ocsmd!stsim!glenn

Perhaps you could make a better guest on your binary search start.  Say
look at the first character and make a guess about where to start in the
file.  You can also branch on much less, less, equal, greater, and much
greater.  This will be a bit faster than a binary search.  You say you
are using a binary search now, so not much more logic is needed.

				Cliff



More information about the Comp.lang.c mailing list