4 ms·
> which converts properly prepared recursion into an iterative loop It only works if you are using recursion in place of a simple loop. Many algorithms tradit
by Const-me 8y ago
> which converts properly prepared recursion into an iterative loop
It only works if you are using recursion in place of a simple loop.
Many algorithms traditionally implemented with recursion (e.g. various tree searches) need that stack somewhere.
Technically it’s probably possible to “properly prepare” that, but practically both alternatives (recursion + built-in call stack, or loop + separate stack) are much easier to implement.