It was thus said that the Great William Donzelli once stated:
I can't
tell you how many students think recursion is the answer to
every question. (Then again, I do deal with a lot of students.
Or how many engineering managers think recursion has no place in
production code.
Yeah, I got chewed out on that one once. While I realized the code may
run in a memory-restricted environment, I was told (in ever so clear terms
after I wrote the code) that STACK SPACE IS A PREMIUM, not data space (ooh,
I still appear to be a bit bitter over that), so of course a bunch of extra
pointers per node was fine, but DON'T USE THE STACK!
Recursion is really neat and clever, and really gives
the academics
the jollies, but is often a big red flag for unreadable,
hard-to-maintain code in the real world.
Depends upon what's being asked. Balanced tree algorithms are a bit nicer
if you can use recursion, and otherwise a right nightmare if you can't. The
major complaint I see against recursion is that it's often taught with
simple examples that are horribly inefficient to use in practice.
-spc (the Linux kernel only uses 8K stacks? Man, the more I learn about
how such stuff *really* works, the more I'm amazed ... )