+ 11
In recursive approach, the function calls itself until the condition is met. And it is slower than iteration (loop), which means it uses more memory than iteration. Recursion is like a selection structure, and which makes code smaller and clean. And a function partially defined by itself. The ability to write recursive functions and to think recursively is an intelligence trait. Additionally, recursion can make things much, much simpler if you know how to do it. On the other hand, recursive functions can be extremely costly especially when it comes to memory... Loops may achieve a performance gain for your program. Recursion may achieve a performance gain for your programmer ;D Want more detailed explanation? • https://stackoverflow.com/questions/2651112/is-recursion-ever-faster-than-looping/2651200#2651200 • http://www.sanfoundry.com/c-tutorials-difference-recursion-iteration/
20th Jul 2017, 3:28 PM
Dev
Dev - avatar