Binary searching

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

can anyone tell me what's the best way to search in binary content? Best if someone could post or link me to some source code (in C/C++).
The search should be as fast as possible and it would be great if the engine (or so) would accept multiple parameters (like a search offset, a max number of bytes to search in etc.)

Any ideas

Thanks a lot again

Gordon
 
Hi,

can anyone tell me what's the best way to search in binary content? Best if someone could post or link me to some source code (in C/C++).
The search should be as fast as possible and it would be great if the engine (or so) would accept multiple parameters (like a search offset, a max number of bytes to search in etc.).
Give us a hint. Are you searching a file? Memory? An array? A
linked list? An access data base?


<<Remove the del for email>>
 
engine (or so) would accept multiple parameters (like a search offset, a max
number of bytes to search in etc.).
Give us a hint. Are you searching a file? Memory? An array? A
linked list? An access data base?

And what are you searching for? A substring? A token? Is the list
pre-sorted?
 
It all depends upon the nature of the search that u r looking for .. if u
will explain the whole nature of search that u wan to have in ur program
then there will be suggestions .. right now ..there is nothing clear. enough
to say some thing .. but as u said u need multiple parameters to be accepted
... then it is easily done .. with functions .. but the prupose is not clear
as yet ..

sam
saleem ullah khan
 
the best way to binary search is to use the C provided library, best because
simplest.
I can't recall what's the name, something like search/find, bsearch....
whatever

yes, it's limited, but 99% it'll work.

the binary search is such a piece of cake to do, that you might as well
doing by yourself.
binary search = also dictionary search, that is calculate the middle element
and compare to your item...
if greater consuider now the second half and redivide otherwise consider the
first half.
it's a logarithmic response it's the best BUT............. how do you have
items inserted ????

consider learning what a Btree is and it's balancing, btree is ideally just
as fast when it comes to searching, because it still goes left/right
dividing each time ......... but it's also immensly fast in inserting
items....

Gordon Knote said:
Hi,

can anyone tell me what's the best way to search in binary content? Best
if someone could post or link me to some source code (in C/C++).
The search should be as fast as possible and it would be great if the
engine (or so) would accept multiple parameters (like a search offset, a max
number of bytes to search in etc.).
 
the binary search is such a piece of cake to do, that you might as well
doing by yourself.

I agree it's a good exercise, but not because it's a piece of
cake. Binary search offers a minefield of off-by-one errors.
Good luck.

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com
 
I know the question involved searches for binary content, but I must digress
to point out a terrific source for sophisticated text-searching algorithms
at Thierry Lecroq's site: http://www-igm.univ-mlv.fr/~lecroq/string/

The site gives excellent theoretical treatment to many text-searching
algorithms.

But most commendably, the site gives C code for the algorithms _AND_ working
Java simulations of the progression of each algorithm.

It's well worth a visit.

Regards,
Mike
 
Michael said:
I know the question involved searches for binary content, but I must
digress to point out a terrific source for sophisticated
text-searching algorithms at Thierry Lecroq's site:
http://www-igm.univ-mlv.fr/~lecroq/string/

The site gives excellent theoretical treatment to many text-searching
algorithms.

But most commendably, the site gives C code for the algorithms _AND_
working Java simulations of the progression of each algorithm.

It's well worth a visit.

Yes - that's a great site! (I'd seen it before, but long ago lost the link
to it).

I'd point out that "binary searching" is in no way different from "text
searching", except that the alphabet is larger (and possibly includes
unprintable characters). That means that all of these "exact string
matching algorithms" are perfectly applicable to binary searching.

-cd
 
andrea said:
the best way to binary search is to use the C provided library, best
because simplest.
I can't recall what's the name, something like search/find,
bsearch.... whatever

yes, it's limited, but 99% it'll work.

the binary search is such a piece of cake to do, that you might as
well doing by yourself.

You're talking about using a binary reduction searching algorithm. The OP
was talking about searching unsorted binary data. Two unrelated topics with
similar names.

-cd
 
Back
Top