Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 840463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T05:37:37+00:00 2026-05-15T05:37:37+00:00

I am looking for a good Tree data structure class. I have come across

  • 0

I am looking for a good Tree data structure class. I have come across this package, but since I am relatively new to Python (not programming), I dont know if there are any better ones out there.

I’d like to hear from the Pythonistas on here – do you have a favorite tree script that you regularly use and would recommend?

[Edit]

To clarify, by ‘Tree’, I mean a simple unordered tree (Hmm, thats a bit of a recursive definition – but hopefully, that clarifies things somewhat). Regarding what I need the tree for (i.e. use case). I am reading tree data from a flat file and I need to build a tree from the data and traverse all nodes in the tree.

  • 1 1 Answer
  • 2 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T05:37:37+00:00Added an answer on May 15, 2026 at 5:37 am

    Roll your own. For example, just model your tree as list of list. You should detail your specific need before people can provide better recommendation.

    In response to HelloGoodbye’s question, this is a sample code to iterate a tree.

    def walk(node):
        """ iterate tree in pre-order depth-first search order """
        yield node
        for child in node.children:
            for n in walk(child):
                yield n
    

    One catch is this recursive implementation is O(n log n). It works fine for all trees I have to deal with. Maybe the subgenerator in Python 3 would help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In C# I have an intrusive tree structure that looks like this: public abstract
I'm looking for a good JavaScript tree / treegrid package. Now -- before you
I'm looking for a good dropdown node tree that has checkboxes. Similar to ASP.NET
Many websites have very good looking pop-up window. For example checkout http://www.myntra.com and when
How to make this subqueries to good-looking code? And I looking guides about SQL
I'm looking for a good way to store and use hierarchical (parent/child) data in
I have a requirement for a Tree grid or Tree list control. This is
I am using Delphi 2009. I have a very simple data structure, with 2
How do I make a tree data structure in C++ that uses iterators instead
I am looking for good practice or pattern to write a lib in JS.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.