Data Structures

Recursion

Recursion is the name given for expressing anything in terms of itself.
A function which contains a call to itself or call to another function ,which eventually causes the first function to be called,is known as a recursive function.

  •  Recursive procedures generally solve a given problem by reducing the problem to an instance of the same problem with smaller input.
  • Once the function is called an activation record is created on the stack
  •  Call to it self is repeated till a base condition is reached.
  • Once a base condition or terminal condition is reached,the function returns the result to previous copy of the function.
  • A sequence of returns ensures that the solution to the original problem obtained.

The recursive procedure(function) must have the following properties

  •  There must be certain condition ,called base condition,for which the procedure(function) does not call itself.
  •  Each time the procedure(function) does call itself (directly or indirectly),it must be closer to the base condition.

Leave a comment

Your email address will not be published. Required fields are marked *