On 06/08/2013 10:27 AM, Fred Cisin wrote:
I have no
problems with iteration or subroutines, so why do we need
recursion?
It IS handy, albeit far from NECESSARY, for walking trees.
One aspect that I've noticed over the years is that, generally speaking,
people who use recursion in memory-limited situations are less able to
accurately tell you how DEEP they can recurse before running out of
memory. The ones who iterate usually can tell you precisely.
Similarly, the one using recursion usually will be able to tell you less
about error recovery than the iterative user.
In practice, there's no really good reason for this to be true, but it
is something that I've noticed.
Recursion and iteration are methods and both have their place--and are
equally disastrous when badly implemented.
--Chuck