473,395 Members | 1,885 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Binary searching

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
Nov 17 '05 #1
8 2335
On Sat, 1 May 2004 12:51:02 -0700, Gordon Knote
<an*******@discussions.microsoft.com> wrote:
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>>
Nov 17 '05 #2

"Barry Schwarz" <sc******@deloz.net> wrote in message
news:c7**********@216.39.134.69...
On Sat, 1 May 2004 12:51:02 -0700, Gordon Knote
<an*******@discussions.microsoft.com> wrote:
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?


And what are you searching for? A substring? A token? Is the list
pre-sorted?

--
-GJC [MS Windows SDK MVP]
-Software Consultant (Embedded systems and Real Time Controls)
- http://www.mvps.org/ArcaneIncantations/consulting.htm
-g*******@mvps.org

Nov 17 '05 #3
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
Nov 17 '05 #4
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" <an*******@discussions.microsoft.com> wrote in message
news:77**********************************@microsof t.com...
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

Nov 17 '05 #5
"andrea catto'" <ac****@dataflight.com> wrote in message
news:u$****************@TK2MSFTNGP11.phx.gbl...
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
Nov 17 '05 #6
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
"P.J. Plauger" <pj*@dinkumware.com> wrote in message
news:ub**************@TK2MSFTNGP12.phx.gbl...
"andrea catto'" <ac****@dataflight.com> wrote in message
news:u$****************@TK2MSFTNGP11.phx.gbl...
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

Nov 17 '05 #7
Michael K. O'Neill wrote:
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
Nov 17 '05 #8
andrea catto' wrote:
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

Nov 17 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: tsunami | last post by:
hi all; I have an array and want to insert all the elements from this array to a binary search tree.That array is an object of the class of a stringtype which includes overloaded "< > = =="...
28
by: wwj | last post by:
void main() { char* p="Hello"; printf("%s",p); *p='w'; printf("%s",p); }
15
by: Foodbank | last post by:
Hi all, I'm trying to do a binary search and collect some stats from a text file in order to compare the processing times of this program (binary searching) versus an old program using linked...
24
by: pristo | last post by:
hello All, how can i insert unique ID into binary file (that created by compiler)? (so after compiling i can to identify the src that i use) thx
10
by: free2cric | last post by:
Hi, I have a single link list which is sorted. structure of which is like typedef struct mylist { int num; struct mylist *next;
3
by: utab | last post by:
Dear all, What are the advantages of binary files over text files? I would like to search for a specific value of a variable in an output file, I was doing this lately by the string library...
6
by: fdmfdmfdm | last post by:
This might not be the best place to post this topic, but I assume most of the experts in C shall know this. This is an interview question. My answer is: hash table gives you O(1) searching but...
4
by: Hunk | last post by:
Hi I have a binary file which contains records sorted by Identifiers which are strings. The Identifiers are stored in ascending order. I would have to write a routine to give the record given...
0
by: Atos | last post by:
Binary search is used to locate a value in a sorted list of values. It selects the middle element in the array of sorted values, and compares it with the target value; that is the key we are...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.