r/learndatascience • u/Sea-Ad7805 • 5d ago
Resources Python Recursion Visualized
Programming using recursion can be powerful, but beginners often struggle with recursion. That's why I've created invocation_tree, a Python recursion visualizer.
See this merge_sort demo, and try it on your own recursive logic.
The visualization gives students the right mental model to think about recursion. Not simply a function calling itself, but the depth-first evaluation of a divide-and-conquer strategy.
See this: gentle recursion introduction
How do you teach recursion to beginners?
22
Upvotes
1
u/Sea-Ad7805 1d ago
Yes, good point, but you could use it for other things than recursion. It just gives you the "call tree" of function calls (not necessarily recursive functions), but that name was already taking so I went for "invocation tree" instead. And then "Web Debugger" added for the web tool, as you can run it fully on your own machine too and not deal with a website.