Binary search tree

Neil Cerutti horpner at yahoo.com
Fri Nov 9 16:28:05 EST 2007


On 2007-11-09, Larry Bates <larry.bates at websafe.com> wrote:
> maxim.novak at gmail.com wrote:
>> I have to get list of URLs one by one and to find the URLs
>> that I have more than one time(can't be more than twice).
>> 
>> I thought to put them into binary search tree, this way
>> they'll be sorted and I'll be able to check if the URL already
>> exist.
>> 
>> Couldn't find any python library that implements trees. Is
>> there some library of this kind in python? Or can I find it
>> somewhere else?
>
> Put them into a set.  You can check for existence (very fast)
> and at the end it is easy to sort.

The set is likely the way to go.

Python's library support for binary search trees consists of the
bisect module.

-- 
Neil Cerutti
Ask about our plans for owning your home --sign at mortgage company



More information about the Python-list mailing list