Recursion is one of the algorithm techniques to solve the problem in Computer programming.
A recursive function is a function that calls itself until some condition is satisfied
Some problems solved with the recursive technique
- Factorial Calculation using Recursive function
- Sum of natural numbers
- Depth-first Search algorithm in binary Tree
Iteration is the opposite of the Recursive technique
Difference Between Iteration and Recursive Techniques
Iterative and Recursive are functions to solve a technical problem
Recursive Function | Iterative Function |
---|---|
Here, Function is called repeatedly until some condition is satisfied, returns the result | Code is executed in for loop and return result |
Function exits when some condition is satisfied | For loop uses initialization, conditional express, and change of its value |
It is slower than Iterative function | It is faster than recursive function |
More Memory | Less memory |
Less Code | More coding |