Quote:
|
Originally Posted by KenWittlief
but with a well thought out data structure, there is nothing you can do with recursion that you cant do better without it.
|
That depends entirely on what you mean by "better". If you mean using less stack space, then iterative is definately the way to go. If you mean faster running time, then this just simply isn't true. For example, the recursive quicksort procedure is generally significantly faster than it's iterative counter-part[1,2]. Also, for some algorithms it's next to impossible to write an iterative solution (alpha-beta searching, for example).
At the same time, some problems that may seem recursive (towers of hanoi[3], fibonacci, etc), often have much more elegant and faster iterative solutions.
The reality is that sometimes recursive algorithms are better for a task, and sometimes iterative ones are. Learn how and when to use both, and you'll be a much better programmer because of it.
[1]
http://www.mathcs.carleton.edu/cours...aj/algory.html
[2]
http://www.mvps.org/vb/hardcore/html...equicksort.htm
[3]
http://hanoitower.mkolar.org/shortestTHalgo.html