🎁 New User? Get 20% off your first purchase with code NEWUSER20 Register Now →
Menu

Categories

Programming Concepts Intermediate

What is Recursion?

A programming technique where a function calls itself to solve a problem by breaking it into smaller subproblems.

Recursion solves problems by having a function call itself with modified parameters until reaching a base case. Classic examples include factorial calculation, Fibonacci numbers, tree traversal, and divide-and-conquer algorithms.

Every recursive solution needs a base case (stopping condition) to prevent infinite recursion. Tail recursion can be optimized by compilers. Some problems are naturally recursive (tree/graph traversal), while iterative solutions may be more efficient for others.

Related Terms

DRY (Don't Repeat Yourself)
A software development principle that aims to reduce code duplication by abstracting common patterns into reusable components.
Clean Code
Code that is easy to read, understand, and maintain — following consistent conventions, meaningful naming, and single-responsibility functions.
Design Pattern
A reusable solution template for commonly occurring problems in software design.
Memoization
An optimization technique that caches function results for given inputs, avoiding redundant computations for repeated calls.
Immutable Object
An object whose state cannot be modified after creation, providing thread safety and predictable behavior in concurrent systems.
Singleton Pattern
A design pattern that restricts a class to a single instance and provides a global point of access to that instance.
View All Programming Concepts Terms →