0
Any looping problem can be solved using recursion is it true?
1 Odpowiedź
+ 2
Yes (almost...).
One important difference is that some problems are *much* easier to solve using recursion as opposed to looping, and vice-versa.
However, recursive solutions have one limitation that loops don't suffer from, the stack size. You can easily overflow the stack with a deep recursion (how deep depends on the actual function, and the stack size, which in-turn (the stack size) depends on the Operating System and configuration), which is something to consider when writing recursive solutions. Though, practically this isn't really an issue, unless if there is a bug in the code, it's something to keep in mind. (this is why i said 'almost...')