Trees

Nicholas Cole nicholas.cole at gmail.com
Tue Jan 20 04:23:50 EST 2015


On Mon, Jan 19, 2015 at 11:52 PM, Devin Jeanpierre
<jeanpierreda at gmail.com> wrote:
> On Mon, Jan 19, 2015 at 3:08 PM, Steven D'Aprano
> <steve+comp.lang.python at pearwood.info> wrote:
>> Zachary Gilmartin wrote:
>>
>>> Why aren't there trees in the python standard library?
>>
>> Possibly because they aren't needed? Under what circumstances would you use
>> a tree instead of a list or a dict or combination of both?
>>
>> That's not a rhetorical question. I am genuinely curious, what task do you
>> have that you think must be solved by a tree?
>
> In general, any time you want to maintain a sorted list or mapping,
> balanced search tree structures come in handy.
>
> Here's an example task: suppose you want to represent a calendar,
> where timeslots can be reserved for something. Calendar events are not
> allowed to intersect.

Maybe because I'm not a computer scientist, I can't immediately see
why this is a "Tree" problem and not a "Database" problem.  Genuinely
interested.



More information about the Python-list mailing list