2 ms·
> It's my uninformed opinion that recursion is uninteresting and unintuitive. Recursion is the use of the built in stack data structure that the compiler manag
by com2kid 11y ago
> It's my uninformed opinion that recursion is uninteresting and unintuitive.
Recursion is the use of the built in stack data structure that the compiler manages for you.
If you are working your way through a data set with a well determined end state that you incrementally approach (be it the end of the list, or getting closer and closer to finding a value in a tree), and you have a need to backtrack, then recursion is a good way to solve the problem.
All recursive code can be rewritten to be non-recursive, you just keep track of your own stack data structure. This can be either not that much work, or a major pain, depending on the exact problem.
- Something1234 11y ago> All recursive code can be rewritten to be non-recursive, you just keep track of your own stack data structure. This can be either not that much work, or a major pain, depending on the exact problem. Bull, a function that is not primitive recursive cannot be rewritten to be non recursive. Sources: https://en.wikipedia.org/wiki/Ackermann_function https://en.wikipedia.org/wiki/Ackermann_function https://www.youtube.com/watch?v=i7sm9dzFtEI https://www.youtube.com/watch?v=i7sm9dzFtEI