Recursion questions
Date: 06/07/06
(Algorithms) Keywords: no keywords
Now I'm looking at this page on recursion, which contains the following the following text:
" Algorithms that are by nature recursive, like the factorial example above, can be coded either as a loop, as in the first example, or as a recursive function, as in the second example. However recursive functions are generally smaller and more efficient than their looping equivalents. "
So, I have two questions about this:
1. Is it really true that everything that one can code recursively can also be coded in an internal looping mechanism? I'm thinking of advanced recursion, such as that encountered when finding the optimal path down a tree, or finding the solution to the stable marriage problem. Without having named loops, it sure seems that there must be some tasks that can only be done with recursion.
2. "However recursive functions are generally smaller and more efficient..."
Huh? I thought recursive solutions almost always took up more space than their iterative counterparts, so this statement just doesn't make sense to me. Maybe someone knows something I don't.
Source: http://community.livejournal.com/algorithms/76936.html