A recursive function is a function that is defined in terms of itself.
Similarly an algorithm is said to be recursive if the same algorithm is invoked in the body.A recursive function can go infinite like a loop.
To avoid in finite running of a recursive function there are 2 properties that recursive function must have.
- Base Criteria :
-
Progressive approach :
The recursive calls should progress in such a way that each time a recursive call is made it comes closer to the base criteria.
There must be at least one basic criteria or condition Such that when this condition is met The function stops calling itself recursively.
Quote: