Recursion Fundamentals

Recursion from scratch. You'll learn the two parts of every recursive function and trace execution step by step.

42 lessons
149 min
Codeforces: 800-1400LeetCode: 1200-1600

Lessons

1. Intro

Why recursion matters

4m

2. Core Concept

Self-calling functions

3m

3. Vocabulary - Base Case

Stopping condition

4m

4. Vocabulary - Recursive Case

Breaking down problems

5m

5. Factorial - Problem Statement

Classic first recursion

4m1 problems

6. Quiz: Base Case

Test your understanding

3m1 problems

7. Factorial - Base Case

What's the simplest?

4m

8. Factorial - Recursive Formula

Breaking it down

3m

9. Factorial - Implementation

Writing the code

4m1 problems

10. Factorial - Walkthrough

Tracing factorial(4)

4m

11. Visualization - Call Stack

How calls stack up

4m

12. Quiz: Call Stack

Testing stack understanding

3m1 problems

13. Lessons from Factorial

summary

4m

14. Sum of Digits - Problem Statement

New application

4m1 problems

15. Quiz: Recursive Structure

Test your understanding

3m1 problems

16. Sum of Digits - Base Case

Single digit

4m

17. Sum of Digits - Recursive Formula

Last digit + rest

3m

18. Sum of Digits - Implementation

Complete solution

4m1 problems

19. Sum of Digits - Walkthrough

Tracing the calls

4m

20. GCD - Problem Statement

Greatest Common Divisor

3m1 problems

21. Quiz: GCD

Knowledge check

3m1 problems

22. GCD - The Key Observation

Why modulo works

3m

23. GCD - Base Case

When to stop

3m

24. GCD - Recursive Formula

The Euclidean algorithm

3m

25. GCD - Implementation

Three lines of code

3m1 problems

26. GCD - Walkthrough

Tracing Euclid's algorithm

4m

27. Challenge: Trace GCD

Manual recursion exercise

4m

28. Power Function - Problem Statement

Computing x^n

3m1 problems

29. Quiz: Power Function

Knowledge check

3m1 problems

30. Power Function - Naive Recursion

The slow way

3m

31. Power Function - The Optimization

Halving the problem

3m

32. Power Function - Base Cases

When to stop

3m

33. Power Function - Implementation

The efficient code

3m1 problems

34. Power Function - Walkthrough

Tracing fast exponentiation

5m

35. Quiz: Optimized Power

Testing power optimization

3m1 problems

36. Lessons from Recursion

summary

3m

37. Pattern - Recursive Decomposition

The general approach

4m

38. Common Recursion Mistakes

Pitfalls to avoid

4m

39. Recursion vs Iteration

When to use each

5m

40. Quiz: Recursion vs Iteration

When to use which

3m1 problems

41. What's Next

Preview of memoization

4m

42. Section Recap

What we learned

3m

Practice Problems

1.
Fibonacci NumberLeetCodeeasy

The exponential to linear speedup that demonstrates why memoization exists - bridges to DP

2.
Petr#Codeforceseasy

Simple string recursion that teaches substring finding with base case identification

3.
Lucky DivisionCodeforceseasy

Digit manipulation through recursion teaches extracting and checking digits one at a time

4.
Pow(x, n)LeetCodemedium

Shows how to handle exponentiation recursively with tricky edge cases like negative exponents

5.

Forces you to find patterns in recursive structures using binary position thinking

6.
JoysticksCodeforcesmedium

Good example for understanding recursive funtions

7.
FactorialHackerRankeasy

Problems like factorial is naturally recursive.

8.
Sum of DigitsCodeChefeasy

Another Application of Recursion(Recursion in Digits)

9.
GCDHackerRankmedium

Recursion in Mathematical Problems

10.
Power of TwoLeetCodeeasy

Perfect for learning power function recursion with bit manipulation

Ready to start learning?

Access all 42 lessons with interactive content and progress tracking.