Recursion Practice Sheet (Before Arrays)
Section 1: Warm-Up Recursion
1. Print numbers from N to 1.
2. Print numbers from 1 to N.
3. Print odd numbers from 1 to N recursively.
4. Print even numbers from N to 1 recursively.
5. Find sum of first N natural numbers using recursion.
Section 2: Return-Based Recursion
6. Calculate factorial using recursion.
7. Calculate a^b using recursion.
8. Find nth Fibonacci number.
9. Find product of first N natural numbers.
10. Count digits of a number recursively.
Section 3: Number Problems
11. Find sum of digits recursively.
12. Reverse a number recursively.
13. Check palindrome number using recursion.
14. Find largest digit in a number recursively.
15. Count occurrences of a given digit in a number.
Section 4: Recursion Tree Thinking
16. Dry-run printZigZag(2).
17. Dry-run printZigZag(3).
18. Count total function calls in factorial(n).
19. Count total function calls in Fibonacci(n).
20. Draw/explain recursion tree of Fibonacci(5).
Section 5: Stair Path & Maze Path
21. Count total ways to climb n stairs (1,2,3 steps).
22. Print all stair paths for n = 4.
23. Count maze paths from (0,0) to (2,2).
24. Print all maze paths from (0,0) to (2,2).
25. Return maze-path count instead of printing paths.