+ 1

Why we require recursion if we already have loop in c???????????????

Why we need recursion, and real world applications of recursion?????????

2nd Apr 2019, 7:06 PM
Amar Singh
Amar Singh - avatar
7 Antworten
+ 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...
3rd Apr 2019, 3:33 PM
Kostas Batz
Kostas Batz - avatar
+ 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
3rd Apr 2019, 3:50 PM
HonFu
HonFu - avatar
0
Algorithms like Quicksort are much easier to implement using recursion.
2nd Apr 2019, 7:52 PM
Vlad Serbu
Vlad Serbu - avatar
0
... and mathematically faster.
2nd Apr 2019, 8:34 PM
Kostas Batz
Kostas Batz - avatar
0
Also computationally?
2nd Apr 2019, 10:32 PM
HonFu
HonFu - avatar
0
It's computationally faster or not than loop????????????
3rd Apr 2019, 7:42 AM
Amar Singh
Amar Singh - avatar
0
Faster than iterations with greater memory consequences.
5th Apr 2019, 6:03 AM
Edison
Edison - avatar