How To Really Understand Recursion
Most tutorials on recursion are misleading!
Recursion is one of those computer science concepts that drives students crazy and makes programmers drool. There is something captivating about it, yet it has certain features that seem out of grasp even for the experienced professionals.
One of the reasons why recursion is tricky is because it is not a native computer science concept; it is a borrowed concept. Recursion is actually a mathematician’s tool by design.
If you look around on the internet, you would find a wealth of “tutorial”-like content trying to explain recursion using programming examples. These “tutorials” are great for computer science students and aspirants to learn the programming logic of recursion.
However, I’m here to argue that these tutorials are doing more harm than good. Part of the problem is what I call “interview recursion” (more on that later). One does not truly learn recursion by simply learning the program logic alone. There is certainly much more to it than meets the eye. And that’s where this essay comes in.
In this essay, we will start with a simple illustration of recursion — first from a mathematical standpoint and then from a programming standpoint.