in reply to Recursion
There are some problems that are better suited to recursion and some that are better suited to looping. Some languages don't give you a choice (for example COBOL has no recursion, ML has no looping). Perl lets you choose. However, it should be noted that a non-recursive solution to a problem is usually at least marginally faster than a recursive solution. But when you convert a recursive algorithm to a non-recursive equivalent you normally end up writing a lot more code and making your program harder to read and support (i've seen 20 lines of recursive code become 200+ lines of non-recursive code). So unless you have a good reason to optimize out the recursion leave it in.
|
---|
Replies are listed 'Best First'. | |
---|---|
RE: Recursion
by Dominus (Parson) on Nov 16, 2000 at 01:59 UTC |