3 ms·
You can run out of stack even if your recursion is guaranteed to terminate. The stack is not infinite. That's why when dealing with very large data sets you mi
by biohacker42 18y ago
You can run out of stack even if your recursion is guaranteed to terminate. The stack is not infinite.
That's why when dealing with very large data sets you might want to prefer iteration over recursion.
Lastly, unless you're allocating (on the stack) in your loop, the loop all by itself will not overflow the stack, even if it never terminates.
- qhoxie 18y agoGood information, but you might want to read the article.
- biohacker42 18y agoThe name StackOverflow refers to an infinite loop or recursion in the programming languages C or C++... I did read the article, the above is what I'm responding to.
- qhoxie 18y agoSorry if I mistook you, I though it was just a post based on the title.
- daleharvey 18y agoof course if you use tail recursion you dont need to increase the stack at all