Difference between recursion and iterations
SNO
|
Iteration
|
Recursion
|
1
|
Iteration has basically four important steps such as initialization condition, executing then updation.
|
There must be an exclusive if statement inside the recursive functions, specifying stopping condition.
|
2
|
It is a process of executing a statement or set of statement repeatedly until some specific condition is specified.
|
It is the technique of defining anything in terms of itself.
|
3
|
Iterative counter part of a problem is more efficient in terms of memory utilization and execution of speed.
|
It is generally a worse option to go for simple problems.
|
Disadvantages of Recursion
There are following disadvantages of recursion:
1. If the recursive calls are not checked properly, then computer may not run out of memory.
2. The recursive calls along with automatic variables are stored on the stack; therefore it consumes lot of memory space.
3. Recursion is not more efficient in terms of speed and execution time.
4. If proper precautions are not taken, then recursion may result non-terminating iterations.