Compare between recursion and iteration.

Iteration

Recursion

It is a process of executing a statement or a set of statements repeatedly, until some specified condition satisfied.

Recursion is the technique of defining anything in terms of itself.

Iteration involves four clear-cut steps like initialization, condition, execution and updating.

There must be an exclusive if statement inside the recursive functions, specifying stopping condition.

Any recursive problem can be solved iteratively.

Not all problems have recursive solution.

Iterative counterpart of a problem is more efficient in terms of memory initialization and execution speed.

Recursion is generally a worse option to go for simple problems, or problems not recursive in nature.

 

Share with

Comments 0

Add your comment