14.01.2011, 20:19, "Ian Kelly" :
> 2011/1/14 kost BebiX ;:
>
>> Well, isn't tree is a root node and it's children?
>
> And its grandchildren, great-grandchildren, etc. What Alex is saying
> is that the implementation you posted traverses the root and its
> immediate children, but does not recur a
2011/1/14 kost BebiX :
> Well, isn't tree is a root node and it's children?
And its grandchildren, great-grandchildren, etc. What Alex is saying
is that the implementation you posted traverses the root and its
immediate children, but does not recur any further than that. That is
why it was so fa
On Fri, Jan 14, 2011 at 11:07 AM, Ian Kelly wrote:
> class PostOrderIter(object):
>
> def __iter__(self, node):
> self.stack = [(node, 0)]
That __iter__ should actually be __init__, of course.
--
http://mail.python.org/mailman/listinfo/python-list
14.01.2011, 18:57, "Alex Boyko" :
> 2011/1/14 kost BebiX
>> 14.01.2011, 14:15, "Alex Boyko" :
>>
>>> 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 recur
On Fri, Jan 14, 2011 at 5:15 AM, Alex Boyko wrote:
> So, I'd like to know how should I implement (if it's possible of course)
> __iter__ for my tree class based on recursion without generators?
You could try something like this (untested):
from itertools import chain, imap
...
def postorde
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:
>
>def post_order(self)
Thank you for your reply, but I have question about your code. Your defined:
def post_order(self):
for child in self.childs:
yield child
yield self
just for "Node" , not for "Tree", and do
w("doing generator post_order...")
_t = datetime.now()
for item in roo
14.01.2011, 14:17, "Alex Boyko" :
> 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)
14.01.2011, 14:15, "Alex Boyko" :
> 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)
14.01.2011, 14:15, "Alex Boyko" :
> 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)
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
11 matches
Mail list logo