4 ms·
Right. Recursion has a problem with stack overflows, but that can sometimes be automatically fixed by turning it into iteration and throwing out the superfluous
by sesqu 16y ago
Right. Recursion has a problem with stack overflows, but that can sometimes be automatically fixed by turning it into iteration and throwing out the superfluous frames. Which one is the special case now?
- eru 16y agoWhy? Iteration. Stacks and stuff are just a way for computers to do some forms of recursion. Recursion itself is just a general mathematical idea. Look at the Natural numbers (http://en.wikipedia.org/wiki/Recursion#Example:_the_natural_numbers http://en.wikipedia.org/wiki/Recursion#Example:_the_natural_...) or dynamic programming (http://en.wikipedia.org/wiki/Recursion#Recursive_optimization http://en.wikipedia.org/wiki/Recursion#Recursive_optimizatio...). Dynamic programming is an interesting case, because in most languages the idiomatic way to express it uses iterative constructs.