RECURSION

I dare you...go to Google and search: "recursion"

No, it is no mistake, you spelled it right (right?). So why is Google telling you that you spelled it wrong? Their spelling is exactly the way you spelled it. Go ahead, click the correction, Google still asks whether you meant “recursion” after they have corrected you.

Knowing the definition of recursion does not suffice in knowing what the term means. Usually it takes experience in order to get the full meaning of recursion, let alone even attempt thinking recursively. It is an inception nightmare. How can you learn about something that can only be learned if you already know what it is?

Recursion is similar to a snake eating its own tail as well as visiting Google to search “Google.”

Recursion is a programming style. A recursive function is one that calls upon itself, and continues to do so until the problem is solved. Intuitively, this makes no sense (If I say, "conflagration" and you have no idea what it means, each time I repeat the word should bring you no closer to its meaning). But once you get it, you will understand why Google made “recursion” a never ending cycle.

Let's say you have a bathtub filled with water. You want to know how many drops of water are in the bathtub. You decide to remove 1 drop. You now know that the total number of drops equals 1(the 1 removed) + the total drops (still in the tub). Now let's remove another drop, leaving the total equal to 1 + 1 + (the new current total). You do this until you have only one drop of water left in the tub. Now you can add up all the other drops you already removed, leaving you with the total drops of water that were in the tub.

The most basic idea of recursion states that the answer to a problem can be expressed by making the problem slightly easier. Each time you call the function within the function, the complexity of the problem is minimized and becomes easier and easier until the last step, the most basic step possible is reached, and every thing can be added from the previous function call until you have the final answer. Of course, doing the above example would take a long time if you were doing it one drop at a time as a human. A computer can speed up this process and is great for handling recursive programming.

Steven Braverman © 2024 - All Rights Reserved