3 ms·
I remember when I was at college it was the same, and it doesn't make any sense. I can't recall any instances where I've needed to convert an iterative solution
by iliketosleep 8y ago
I remember when I was at college it was the same, and it doesn't make any sense. I can't recall any instances where I've needed to convert an iterative solution into a resursive one, but there have been countless times I've done the reverse. I belive that the mindless emphasis on resursive programming in college courses has lead to poor practices, where people are using recursion to just make their code more elegant where an iterative solution wouldn't much more complicated but a lot more robust. The result? Down the track, an unforseen use cases resulting in max stack size exceeded errors, causing needless headaches.
- saagarjha 8y ago> I belive that the mindless emphasis on resursive programming in college courses has lead to poor practices, where people are using recursion to just make their code more elegant Most courses, especially introductory ones, don’t have particularly good examples of when to use recursion. This doesn’t mean that there aren’t cases where recursion isn’t useful, though.
- gh02t 8y agoI think the prevalence of recursion might be attributable to mathematics. A lot of mathematical analysis of algorithms is more natural to express in terms of recursion (partially because of proof by induction), so you often see algorithms stated that way. It's also worth noting that there are plenty of instances where (IMO), recursion is much more natural. For example, traversing trees recursively. I agree, though, there should definitely be more time spent teaching how to convert between the two.