Recursion.
Recursion consists of method/function code that calls itself repeatedly. The problem that the function is trying to solve is divided into small identical steps/subproblems. The recursive function calls itself till it reaches that last step or lowest level where no further steps are needed to solve the problem (base case). The subproblem is solved at the base case/lowest level and the solution is returned to the previous level, where again the subproblem at that 2nd last level is solved and the combined solution for last 2 levels is returned to the third last level, and so on, till we reach the topmost level. At the top most level the solutions to all subproblems from lower levels is combined to form the complete solution of the original problem to be solved.
Use cases for recursion
We can use recursion to break complex problems / algorithms into smaller understandable parts. Some common applications of recursions are in following areas:
| Searching algorithms. |
| Sorting algorithms. |
| Tree traversal. |
| Graph traversal. |
| Matrix Traversal. |
| Image processing. |
| About Us | Privacy Policy | Contact us |