Back to Developer Roadmap

Recursion

src/data/roadmaps/datastructures-and-algorithms/content/[email protected]

4.0805 B
Original Source

Recursion

Recursion is a method where the solution to a problem depends on solutions to shorter instances of the same problem. It involves a function calling itself while having a condition for its termination. This technique is mostly used in programming languages like C++, Java, Python, etc. There are two main components in a recursive function: the base case (termination condition) and the recursive case, where the function repeatedly calls itself. All recursive algorithms must have a base case to prevent infinite loops. Recursion can be direct (if a function calls itself) or indirect (if the function A calls another function B, which calls the first function A).

Visit the following resources to learn more: