How To Really Understand Recursion

Most tutorials on recursion are misleading!

Hemanth
Street Science

--

How To Really Understand Recursion — An illustration of four recursive dolls, where the biggest doll on the left opens up to reveal a smaller doll. This doll in turn opens up to reveal an even smaller doll, and so on. Three dolls from left to right are drawn using pink and black dual colour tones. On the extreme right, the last doll uses inversed pink and black colour tones. Below the dolls, the text “RECURSION” is written in all pink, except “N”, which is in black.
Illustrative art created by the author

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.

--

--