# Recursion

What is the basic principle behind recursion, other than function calling itself again & again and in which real time scenario we use it?

#### anandkumarjha Profile Answers by anandkumarjha Questions by anandkumarjha

• Aug 28th, 2010

Recursion is the process of calling function again and again.
During the recursion many push and pop operation is done in our registers memory. That's why recursion has very poor performance.
Our computer takes more memory to perform any recursive operation.
If you want to perform a speedy operation you must have to go with looping.

#### jbode Profile Answers by jbode

• Oct 4th, 2010

The basic idea behind recursion is that you're solving one big problem by breaking it into multiple smaller, easier-to-solve problems.  This can make the algorithm easier to write and understand, and it can offer significant improvement in execution time.  For example, the recursive Quicksort algorithm can order a list of values in O(n lg n) operations (average case), as opposed to a non-recursive in-place sorting algorithm like a selection sort (which is O(n^2)).

There are some recursively defined functions (factorials, Fibonacci sequences, etc.) where a recursive implementation is not optimal, and are better computed using an iterative loop or an algebraic solution.