4 ms·
I agree with your first two sentences. Why should recursion be out? You just need to be careful with it. Not having an infinite recursion is basically the sa
by eru 15y ago
I agree with your first two sentences.
Why should recursion be out? You just need to be careful with it. Not having an infinite recursion is basically the same problem as not having an infinite loop.
- rgoddard 15y agoSince with recursion you can have a large but finite number of calls that could blow the stack, but not have the same problem with a for loop.
- eru 15y agoYes, you have to account for that. Also, tail recursion should be fine, if your compiler is smart enough. (I guess since the program is looking at assembly, it couldn't tell optimized tail recursion from a loop.)
- wlievens 15y agoIf you want to prove the maximum stack usage of a recursive evaluation, you need to prove how deep it goes. Since that would depend on the inputs, you need to statically determine the limits on the inputs. It's all possible, but cases where it applies would be rare.