3 ms·
Well, when I want to convert a function that uses recursion but the stack isn't big enough, I make it have a queue where each new item goes on the end, and the
by zandorg 16y ago
Well, when I want to convert a function that uses recursion but the stack isn't big enough, I make it have a queue where each new item goes on the end, and the next item goes from the front of the queue. This way the stack is replaced by the heap (which is much bigger!).