Binary Trees in Python

Roy Smith roy at panix.com
Sat Aug 20 15:19:55 EDT 2005


In article <mailman.3314.1124564952.10512.python-list at python.org>,
 [diegueus9] Diego Andrés Sanabria <zessa9 at gmail.com> wrote:

> Hello!!!
> 
> I want know if python have binary trees and more?

Python does not come with a tree data structure.  The basic data structures 
in Python are lists, tuples, and dicts (hash tables).

People who are used to C++'s STL often feel short-changed because there's 
not 47 other flavors of container, but it turns out that the three Python 
gives you are pretty useful.  Many people never find a need to look beyond 
them.

If you do need to go beyond them, it's easy enough to build your own.  
Here's one example of a binary ordered tree that you might find useful:

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/286239



More information about the Python-list mailing list