Whither binary search?
skip at pobox.com
skip at pobox.com
Tue Sep 26 16:11:26 EDT 2006
Neil> On 2006-09-26, skip at pobox.com <skip at pobox.com> wrote:
>> bisect...
Neil> That doesn't tell me if an item doesn't exist in the sequence
Neil> though, does it? Maybe I'm being dense.
Neil> My guess nobody keeps their sequences sorted in Python. ;)
Sorry, I was on the phone as I replied, and was only typing with my left
hand, so my response was intentionally very brief. ;-)
If you use bisect to do your insertions, your lists remain sorted. And as
for searching, all you have to do is look to the left or the right of the
insertion point (depending on which search method you call) to determine if
the item you're searching for is in the list.
Skip
More information about the Python-list
mailing list