+ 1
Why we require recursion if we already have loop in c???????????????
Why we need recursion, and real world applications of recursion?????????
7 Answers
+ 2
well digging the problem in more depth, it seems that in almost any programming language, a loop is slightly faster than a recursion. Well it makes sense to me now, as converting any program to assembly, recursion takes more steps to execute, thus more time than a loop. So no. Recursion is not faster than loops.
You could test this on yout own, by writing a simple piece of code and meausure the time that takes one method over the other.
As for the original question why to use a recursive method, well, i think is mostly for scientific purposes, as we use them a lot in my college. But practically, i have never used one...
+ 1
Actually I have written such a test for Python lately in case you want to take a look...
https://code.sololearn.com/cp50oajs4Wo4/?ref=app
0
Algorithms like Quicksort are much easier to implement using recursion.
0
... and mathematically faster.
0
Also computationally?
0
It's computationally faster or not than loop????????????
0
Faster than iterations with greater memory consequences.