Pune Media

Recursion — Data Structures & Algorithms for Data Scientists | by Egor Howell | Nov, 2024

Recursion, recursion, recursion, recursion, recursion, etc.

Towards Data SciencePhoto by Voicu Apostol on Unsplash

Recursion is one of the most famous concepts in computer science because it’s quite fun!

In this article, I will explain recursion and its different types and show you some famous examples.

Recursion is when a function calls itself, but the input will typically change. So, as the function is calling itself, it’s known as a recursive function.

You are essentially breaking down the problem into more minor problems, which are solved independently but added together step by step.

Pretty much every recursive function can be written in a loop format, but the recursive framing is often much more elegant!

A Russian Doll can be considered a recursion, as each doll contains another doll, then that one contains another etc.

Recursion could technically go on forever, but there are often some stopping criteria that prevent this. Otherwise, the computer will quickly run out of memory!

In general, a recursive function has two things:

  • Base Case — Terminating scenario that does not require recursion.



Images are for reference only.Images and contents gathered automatic from google or 3rd party sources.All rights on the images and contents are with their legal original owners.

Aggregated From –

Comments are closed.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More