0

Recursion

can any one explain what is the difference between recursion & loop?

13th Oct 2016, 4:38 PM
Nishant Kumar
Nishant Kumar - avatar
2 odpowiedzi
0
The loop is repeated a fixed number of times until a condition is met. Recursion is when a procedure calls itself with different parameters.
13th Oct 2016, 4:46 PM
Nadezhda
0
In many cases a loop and recursion can accomplish the same task, but the loop will tend to go faster. Unfortunately, the way that most people teach recursion (factorials) is not that great/intuitive and a loop will actually work faster because it won't have to store so many function calls in memory. Bottom line, they are fairly interchangeable for 99% of circumstances. And when they are interchangeable, it would probably be most efficient and understandable to use a loop.
13th Oct 2016, 7:35 PM
Ryne
Ryne - avatar