Recursive to non-recursive
Quote:
> > Does anybody have sample code about using non-recursive algorithm replace a
> > recursive code, such like visiting a tree structure?
>For some algorithms it is inherently impossible to replace the recursive
>algorithm by a non-recursive one. Think about the Ackerman function.
Of course you can transform every recursive algorithm with a
non-recursive one using an explicit stack. That includes
Ackermann. There are turing-complete algorithmic models that do
without any recursion, e.g. the minimalistic PL language (or
fortran)
or the Turing-machine itself.
Quote:
>For a tree structure, if you add some information to every node, a
>non-recursive algorithm is possible. But there are other newsgroups
>dealing with this.
Correct. Followup set.
Stephan
--
-------------------------- It can be done! ---------------------------------
----------------------------------------------------------------------------