Re: Tree library - multiple children

Discussion in 'Python' started by Michael Torrie, Dec 12, 2013.

  1. On 12/12/2013 11:14 AM, Ricardo Aráoz wrote:
    > I need to use a tree structure. Is there a good and known library?
    > Doesn't have to be binary tree, I need to have multiple children per node.


    There are lots of types of tree structures that may or may not be
    applicable to your problem. And it depends on what kind of data you're
    storing. For example, I wrote a parser years ago (in C) that processed
    BER-encoded structured data (sort of like binary xml). Turned out that
    the nested structure of BER-encoded data lends itself well to
    "left-child, right-sibling" trees (and it happens to be binary, which
    makes for easy traversal).

    In any even Python's data primitives are powerful enough that you don't
    need a library at all. Just use Python's built-in primitives. You can
    do most tree structures with just list manipulation, without any class
    overhead at all.

    In fact in my case, my "left-child right sibling" trees are by
    definition lists (think LISP car and cdr) or tuples. The LISP-esque
    nature of Python's data types always did make Python appeal to me.
    Michael Torrie, Dec 12, 2013
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ricardo Aráoz

    Tree library - multiple children

    Ricardo Aráoz, Dec 12, 2013, in forum: Python
    Replies:
    2
    Views:
    80
    Ricardo Aráoz
    Dec 13, 2013
  2. Terry Reedy

    Re: Tree library - multiple children

    Terry Reedy, Dec 12, 2013, in forum: Python
    Replies:
    0
    Views:
    57
    Terry Reedy
    Dec 12, 2013
  3. Neil Cerutti

    Re: Tree library - multiple children

    Neil Cerutti, Dec 12, 2013, in forum: Python
    Replies:
    0
    Views:
    56
    Neil Cerutti
    Dec 12, 2013
  4. Joel Goldstick

    Re: Tree library - multiple children

    Joel Goldstick, Dec 12, 2013, in forum: Python
    Replies:
    0
    Views:
    57
    Joel Goldstick
    Dec 12, 2013
  5. MRAB
    Replies:
    0
    Views:
    54
Loading...

Share This Page