Yes, recursion is often (even usually) easier to understand and easier to implement correctly on the first try. Non-recursive solutions are likely to only be a little bit faster. But, recursive solutions are likely to fail on much "smaller data" and prevent you from providing certain types of interfaces compared to non-recursive solutions. So I prefer non-recursive solutions if I suspect that efficiency will be unusually important, I want to succeed with as large of data as possible, or I want to provide the best possible API (such as if I'm writing code for public reuse).
I go over this in a bit more detail here: (tye)Re: Recursion. The rest of that thread may also be of interest.
Also, one thing I didn't mention before: People sometimes turn to recursive solutions when a simple loop (not even requiring a stack) would make more sense (as in the thread you link to). In such cases, the recursive solution is likely to be harder to understand and to get right on the first try. So, if you find yourself contemplating a recursive solution, you should at least think a bit about how you might solve it without recursion. (:
- tye (but my friends call me "Tye")In reply to (tye)Re: bushy recursion a good thing ?
by tye
in thread bushy recursion a good thing ?
by mandog
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |