Turning Learners Into Developers
Codekilla
CODEKILLA
back to course
Lesson 18 / 14912%
Algorithm & Complexity Analysis10/10

Recursion Basics & Analysis

Function calling itself — and how the stack pays for it.

int fact(int n) { return n <= 1 ? 1 : n * fact(n - 1); }fact(4)→ 4 * fact(3)fact(3)→ 3 * fact(2)fact(2)→ 2 * fact(1)fact(1)base: return 1→ unwinds: 1 → 2 → 6 → 24
Visual explanation diagram · click steps to walk through it

This lesson is Pro only.

Unlock every premium lesson and module — Pro from ₹299 / month (or ₹999 / year, saves ~₹2,589).

Sign in to unlock
// feedback.matters()
Did this lesson help you?