Re: iterative copying of binary expression trees
- From: tar@xxxxxxxxxxxxx (Thomas A. Russ)
- Date: 22 May 2009 12:28:59 -0700
Jean Guillaume Pyraksos <wissme@xxxxxxxxxxx> writes:
Pascal, I don't understand your reply. I want to find a one-phase algorithm
to solve this problem of copying in a functional iterative way a binary tree.
I have already a two-phase algorithm.
I'm just asking : does anyone know a one-phase algorithm ?
I'm not a student, I'm trying to get my program done in the best way...
Well, I would think that the best way would be to use a recursive
algorithm.
Tree walkers belong to a class of functions that are fundamentally
recursive. The class of recursive functions is larger than the class of
iterative functions, so you can't really have a purely iterative
solution to this problem. At best you can not use the built-in
recursion and instead implement it yourself by maintaining a stack or
queue of pending operations that you will need to execute.
Since a tree walker is fundamentally a recursive function, you can't
have a proper tail-recursive version. Simply because the algorithm
requires doing things via multiple recursion along different branches of
the tree walk. Again, you could probably disguise it, but any such
solution will be a lot more convoluted than a straight-forward recursive
solution.
Why are you interested in an iterative solution?
--
Thomas A. Russ, USC/Information Sciences Institute
.
- References:
- iterative copying of binary expression trees
- From: Jean Guillaume Pyraksos
- Re: iterative copying of binary expression trees
- From: Pascal J. Bourguignon
- Re: iterative copying of binary expression trees
- From: Jean Guillaume Pyraksos
- iterative copying of binary expression trees
- Prev by Date: Re: Seeking computer-programming job (Sunnyvale, CA)
- Next by Date: Re: macros
- Previous by thread: Re: iterative copying of binary expression trees
- Next by thread: Re: iterative copying of binary expression trees
- Index(es):
Relevant Pages
|