So I mean, your approach with generators showed good results in terms of
time efficiency 'cos iteration was done for root and root's children.
On 14 January 2011 18:57, Alex Boyko wrote:
> Thank you for your reply, but I have question about your code. Your
> defined:
>
>
datetime.now()
for item in root.post_order():
fake = item.value
w("done\n")
w(datetime.now() - _t)
w("\n")
what give us only iterating along root's children, not iterating along
tree...Or I didn't catch your though?
Best Regards
Alex
2011/1/14 k
Dear All!
I have deal with large unbalanced trees and I have to implement post-order
tree traversal. My first attempt is shown below ("Node" and "Tree" classes)
and based on recursive generators approach.
class Node():
def __init__(self,value):
self.childs = []
self.value = va