[Python-ideas] A tree data structure for Python

Stephan Foley foley12723 at gmail.com
Wed Feb 17 12:52:51 EST 2016


Hello and thanks for the reply.

On Wed, Feb 17, 2016 at 12:30 PM, Andrew Barnert <abarnert at yahoo.com> wrote:

> Do you want it to be fixed-n-ary or arbitrary branching? Values in all nodes, or only the leaves? Does it need O(1) size or depth? Single-linked, back-pointers, or threaded? Mutable or copying? Are trees and nodes separate types (and, if so, is a subtree a tree in its own right)? What algorithms do you need besides BFS and DFS (pre-, in-, and post-order) visits?

Yes, I'm looking online and neither C++ nor Java have a tree class for
the same reason. Rolling your own tree is very easy, but developing
something useful for everyone can involve a lot of overhead.

But, to answer your questions, a lightweight tree that could represent
either a file system or configuration data. Arbitrary branching.
Values in all nodes. Pointers to first child, next sibling and parent.
Based on a node class. Pre-order, post-order and level-order
traversal.


More information about the Python-ideas mailing list