What is the difference between Recursion and Iteration

Recursion Iteration
Definition Recursion is a process of executing certain set of instructions repeatedly by calling self function or method repeatedly. Iteration is the process of executing certain set of instruction repeatedly, without calling the self function or method.
Efficiency The recursive method are less efficient. The iterative methods are more efficient because of their execution speed.
Memory Utilization More memory is utilized in Recrusion Less memory is utilized in interation
Program Size Recursive methods give compactness to our program. Lines of code is comparatively greater in interation.
Complexity Recursion is quite complex to implement. Its less complex.

Summary :

1) Recursive function – is a function that is partially defined by itself whereas Iterative functions – are loop based imperative repetitions of a process.
2) Recursion Uses selection structure whereas Iteration uses repitation structure.
3) An infinite loop occurs with iteration if the loop-continuation test never becomes false whereas infinite recursion occurs if the recursion step does not reduce the problem in a manner that converges on the base case.
4) Iteration terminates when the loop-continuation condition fails whereas recursion terminates when a base case is recognized.
5) When using recursion multiple activation records are created on stack for each call when in iteration everything is done in one activation record.
6) Recursion is usually slower then iteration due to overhead of maintaining stack whereas iteration does not use stack so it’s faster than recursion.
7) Recursion uses more memory than iteration.
8) Infinite recursion can crash the system whereas infinite looping uses cpu cycles repeatedly.
9) Recursion makes code smaller and iteration makes code longer.

I hope this post was helpful to you guys. Please subscribe to the blog feed if you like my posts.