Difference Between Recursive and Iterative
Recursive:
It is a process of solving a problem by reducing it to smaller versions of itself. Recursive is a technique that allows us to break down a problem into one or more sub-problems that are similar in form to the original problem.
Iterative:
Iterative is a process of executing a statement or a set of statements repeatedly until some specific condition satisfied.
Recursion vs iteration:
Recursive | Iterative |
1. It is the technique of defining anything in terms of itself. | 1. It is a process of executing a statement or a set of statements repeatedly until some specific condition is satisfied. |
2. There must be an exclusive if statement inside the recursive functions, specifying stopping condition which indicates the base criteria. | 2. Iteration involves four clear cut steps : Initialization, condition, execution, and updation. |
3. Not all problems have recursive solution. | 3. Any recursive problem can be solved. |
4. It is generally a worse option to go for simple problems. | 4. It is more efficient in terms of memory utilization and execution speed. |