...
An iterative solution is often completely different from the recursive solution.
>>15 is a shitty iterative prefix tree traversal -- the recursive variant looks like this:
def traverse( node, func ):
if not func: return
func( node )
traverse( node.left, func )
traverse( node.right, func )
It doesn't use tail recursion. It
can't use tail recursion. In order to avoid raping the fuck out of your stack, you
must use an iterative approach like the one above.
Tail recursion is the same goddamn thing as an iterative approach -- any tail recursive function can be wrappered into a loop which does the same thing (and this is what any self-respecting compiler does for you), and any iterative loop can be restructured into a tail-recursive function. A true recursive function (qsort, tree traversal, etc) is such that it
is not tail recursive, but rather, branches out.