Definition:
Recursion means writing procedures and functions which call themselves.General algorithm:
Method: solving large problems by breaking them into smaller problems of identical forms
Eventually a "trivial" problem is reached that can be solved immediately.
Initially it may seem that the solution is incomplete.
if stopping condition then
solve simple problem
else
use recursion to solve smaller problem(s)
combine solutions from smaller problem(s)
Terminated Stage:
There is one further iterative program control technique, known as recursion.
A recursive iteration involves a subprogram calling itself, directly or indirectly.
If a subprogram simply called itself as a part of its execution, then
the called execution would itself call a further execution, which would itself call itself
and there would be no end to the number of calls made. This situation
is known as infinite recursion and is similar to the fault in indefinite loops where
a faulty loop control condition causes the loop to iterate infinitely. To avoid an infinite loop,
the loop control condition has to be very carefully constructed in order to ensure that
at some stage it can be guaranteed that it will cause the loop to terminate.
To avoid infinite recursion, the recursive subprogram has to be carefully constructed to
ensure that at some stage the subprogram terminates without calling itself.