Recursion is one of those topics where I think a lot of people have a hard time going from reading about it to grasping it in practical terms. I know for myself that it was easy to learn the core jargon around recursion, such as base case, pre-order, in-order, post-order, etc, but I still found the concept difficult to wrangle with in practice.
We sometimes say that people are visual learners, and I believe that's definitely the case for myself. I can learn all about the concepts, but if I can't see it, it will be harder for the idea to truly click.
Visualizing is my first step when trying to follow what a recursive function is doing, but that can be difficult when the function is complicated, or there are just too many calls to follow.
So, just to scratch my own itch, I built a little tool that can sketch out recursion as it happens. You write a function, and the tool draws it out for you. Let's take a look at some examples from it. Hopefully it will help recursion click for you!
Here we have the example of all examples when it comes to recursion. If you've read about recursion, you've probably seen an explanation of the Fibonacci sequence.
So this one is a little less done to death. How many different ways could you jump up 4 steps, if you can take steps 1, 2, or 3 at a time? Let's find out.
Want to see how your own function looks? The app accepts functions in a little made up language that mostly looks like any C style code.
I hope you enjoy!