Recursion

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

Questions by masveera   answers by masveera

Showing Answers 1 - 4 of 4 Answers

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.

  Was this answer useful?  Yes

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. 

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions