Recursion

Last updated

What is 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).

Free resources to learn Recursion

More in stage 14: Problem Solving Techniques

Recursion: common questions

Can I learn Recursion in Hindi?

This lesson is written in English. Once you sign in, open it in the interactive course and ask the AI tutor to explain Recursion in Hindi or Hinglish. The tutor answers from this lesson’s own text, so it stays on the syllabus, and it runs on your own Google, OpenAI or Anthropic key.

Is this Recursion tutorial for beginners?

It is lesson 98 of 107 in the free Data Structures & Algorithms roadmap, in stage 14, Problem Solving Techniques. If you are new to Data Structures & Algorithms, start from stage 1 and come back here in order; if you already know the earlier stages, this lesson stands on its own.

Still confused? Ask me