What is Recursion? | Concepts of Recursion


Posted August 5, 2020 by brainmentors

The process in which a function calls itself is called recursion. Recursion is a method where the solution of a problem depends upon the solutions that are small instances of the same problem.

 
Why we need recursion?
Any problem can be solved by a recursive method as well as by the iterative method. But whenever we have a problem that is complex to do just by iterative/looping method. Then we are going to divide the problem into a smaller instance of the same problem that means we solve it by the recursive method.


What is call Stack?
A call stack is a stack data structure that is used to trace the sequence of the function call. When a function called then it’s get pushed inside the stack and when a function returns it popped out from the stack.

Three Concepts of Recursion
Base Case (Terminating Case)
Small Problem
Processing Logic
Types of Recursion:
Tail Recursion:

If a recursive function is calling itself and that recursive call is the last statement in the function. After that call there is nothing, it is not performing anything.

Head Recursion:

If a recursive function is calling itself and that recursive call is the first statement in the function and some operations are performed after the call. The function doesn’t have a processor to perform any operation at the time of calling. It has to do everything at the time of returning.

Linear Recursion:

A linear recursive function is a function that only makes a single call to itself each time the function runs. It has something to process before and after the call.

Read Full Article Here – https://brain-mentors.com/what-is-recursion/
-- END ---
Share Facebook Twitter
Print Friendly and PDF DisclaimerReport Abuse
Contact Email [email protected]
Issued By Brain Mentors Pvt. Ltd.
Phone 07042434524
Business Address [email protected]
Country India
Categories Education
Tags concepts of recursion , recursion vs iteration , what is recursion
Last Updated August 5, 2020