Recursion vs Iteration - Differences between Recursion and Iteration written by Nischal Lal Shrestha.
Image of Nischal who is author of the post.

By Nischal Lal Shrestha

On Tue 05 June 2018

Recursion vs Iteration - Differences between Recursion and Iteration

The main difference between recursion and iteration is that Recursion is the technique of defining anything in terms of itself while Iteration is a process of executing a statement or a set of statements repeatedly.

Below is the difference table between recursion vs iteration

Recursion vs Iteration

S.N Recursion Iteration
1 Recursion is the technique of defining anything in terms of itself. Iteration is a process of executing a statement or a set of statements repeatedly, until some specified condition is satisfied.
2 There must be an exclusive if statement inside the recursive function, specifying stopping condition. Iteration involves four clear-cut Steps like initialization, the condition, execution, and updating.
3 Not all problems have recursive solution. Any recursive problem can be solved iteratively.
4 Recursion is generally a worse option to go for simple problems or problems not recursive in nature. Iterative counterpart of a problem is more efficient in term of memory utilization and execution speed.
5 Recursion is more of a top-down approach to problem-solving in which the original problem is divided into smaller sub-problems Iteration follows a bottom-up approach that begins with what is known and then constructing the solution step by step.
6 When Reading recursive code it is sometimes very hard to see how it solves the problem. Iterative codes are more readable than the recursive codes.

Comments