A hands-on Jupyter notebook that teaches recursive programming in Python through clear explanations, side‑by‑side iterative comparisons, simple performance checks, and practice exercises.
- practical_recursion.ipynb— a guided notebook covering fundamentals, patterns, performance, and 10 practical case studies.
| Case | Topic | Difficulty | Key Concept | 
|---|---|---|---|
| 1 | Factorial | Easy | Linear recursion basics | 
| 2 | Fibonacci | Medium | Binary recursion, exponential growth | 
| 3 | Sum of List | Easy | Processing sequential data | 
| 4 | Power Function | Easy | Mathematical recursion | 
| 5 | Reverse String | Easy | String manipulation | 
| 6 | Countdown | Easy | Visual recursion flow | 
| 7 | Palindrome Checker | Medium | Two‑pointer recursion | 
| 8 | GCD (Euclidean Algorithm) | Medium | Classical algorithm | 
| 9 | Binary Search | Medium | Divide & conquer | 
| 10 | Nested List Sum | Hard | Deep recursion with nested structures | 
- Python 3.8 or newer
- Jupyter (Notebook or JupyterLab)
- Optional: VS Code with the Python and Jupyter extensions
- Create and activate a virtual environment (recommended):
python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install jupyter- Launch Jupyter in this folder and open the notebook:
jupyter notebook  # or: jupyter lab- In the UI, open practical_recursion.ipynb, then run cells top‑to‑bottom.
- Install the "Python" and "Jupyter" extensions.
- Open the folder, then open practical_recursion.ipynb.
- Select the .venvinterpreter if prompted and click "Run All".
- Start by writing a correct base case; then add the recursive case.
- Use small inputs to trace the call stack and verify the flow.
- Compare recursive vs iterative implementations to understand trade‑offs.
- Python’s default recursion depth is ~1000; deep recursion may raise RecursionError. Prefer iterative or optimized approaches, or redesign to avoid deep stacks.
- "command not found: jupyter":
- Ensure the venv is active and run pip install jupyter.
- If using JupyterLab, install with pip install jupyterlaband launchjupyter lab.
 
- Ensure the venv is active and run 
- VS Code can’t find kernel/interpreter:
- Select the .venvinterpreter from the top‑right kernel picker in the notebook.
 
- Select the 
- RecursionError:
- Reduce input size, switch to an iterative approach, or apply memoization/alternative patterns.
 
This project is released under the MIT License.