Binary search

David Brown david at no.westcontrol.spam.com
Wed Jan 15 10:02:01 EST 2003


"Rudy Schockaert" <rudy.schockaert at pandora.be> wrote in message
news:4OcV9.12866$ym5.2006 at afrodite.telenet-ops.be...
> Hi,
>
> I'm looking for a function that allows me to do a binary search in a file.
> By binary search I mean searching for a sequence of bytes and not the
binary
> search as in the Python Cookbook
> (http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/81188)
>
> Can anyone point me in the good direction?
>

To do a binary search, the file you are searching through must be ordered.
If you are talking about searching for an arbitrary sequence of bytes in a
file, then it does not make sense to talk about it being "ordered".  So you
are almost certainly going to have to do a linear search through the file.







More information about the Python-list mailing list