?
=?ISO-8859-1?Q?=5Bdiegueus9=5D_Diego_Andr=E9s_Sana
Hello!!!
I want know if python have binary trees and more?
I want know if python have binary trees and more?
[diegueus9] Diego Andrés Sanabria said:Hello!!!
I want know if python have binary trees and more?
Yea, binary trees are more data structures as opposed to libraries:[diegueus9] Diego Andrés Sanabria said:Hello!!!
I want know if python have binary trees and more?
[diegueus9] Diego Andrés Sanabria said:Hello!!!
I want know if python have binary trees and more?
[diegueus9] Diego Andrés Sanabria said: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.
Neither C++ nor Python has tree structures in their standard
libraries. I assume that's because there is no single interface that
is proven to suit everybody's needs.
Jorgen said:Uh, the STL has seven flavors:
- vector
- deque
- list
- set
- map
- multimap
- multiset
so that's not too bad for a static language. Each of them
is vital for some purpose, but vector and map are by far the
most commonly used.
Neither C++ nor Python has tree structures in their standard libraries. I
assume that's because there is no single interface that is proven to suit
everybody's needs.
[Jorgen Grahn]
Neither C++ nor Python has tree structures in their standard
libraries. I assume that's because there is no single interface that
is proven to suit everybody's needs.
It is already easy writing "tree constants" using recursive tuples or
lists. To process simple trees in Python, I usually subclass some
Node type from list, and write the traversal methods that suit the
application. The sub-classing already allow for indexing sub-nodes by
"self[index]", and iterating over all by "for subnode in self:", etc.
In my experience, it all goes pretty easily, while staying simple.
However, things related to balancing, finding paths between nodes, or
searching for patterns, etc. may require more work. There are surely
a flurry of tree algorithms out there. What are the actual needs you
have, and would want to see covered by a library?
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.