On Thu, May 19, 2011 at 4:20 AM, Raymond Wiker <raw@rawmbp-2.local> wrote: >> You are right that I assumed parent pointers of some description; >> but it does demonstrate that tree walks can be done iteratively, >> without keeping a stack of any sort. > > Except that the chain of parent pointers *would* constitue a > stack.
Howso? It's part of your data structure, not part of your algorithm; and it's not something that grows and shrinks as you traverse. These considerations may be crucial if, for instance, you want to walk your tree in a signal handler, and you don't know how much memory is available to you... Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list