The topic of recursion can be intimidating and daunting at first to newcomers, and one can get frustrated and find difficulties wrapping their heads around this topic. 🤔
MIT OpenCourseWare
Prof. Eric Grimson framed recursion in a straightforward and easy to understand way. He also introduced a simple yet powerful concept that goes with recursion called memoization. 🤯
One can think of memoization is essentially a list of performed tasks and its values, and if the task at hand is in the list, just get the value; else add the task and value to the list.😀
Notes:
Here is a great resource for Python beginners on recursion:
![ejbarba](https://res.cloudinary.com/practicaldev/image/fetch/s--ogX1lJip--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://media.dev.to/cdn-cgi/image/width%3D150%2Cheight%3D150%2Cfit%3Dcover%2Cgravity%3Dauto%2Cformat%3Dauto/https%253A%252F%252Fdev-to-uploads.s3.amazonaws.com%252Fuploads%252Fuser%252Fprofile_image%252F242461%252F55f88329-6a62-4687-8646-377fbc743c0c.jpg)
Recursion in Python(A Gentle Introduction)
Elijah Jeremiah L. Barba ・ Dec 16 '19
Jokes aside, after watching the video, you're at least a little confident with recursion👏👏👏 Happy Coding!
Top comments (1)
Cool post-Elijah!, Memoization works great for recursion! Although it kinda sounds like Tweety bird pronouncing memorization the same way he pronounces "I thought I thaw a putty cat". Nevertheless here is how you can implement it in Python.
Instead of doing this which consumes a lot of memory:
You add memoization to optimize the recursion:
Or you can also use a builtin python tool:
Here is the complete video explaining it clearly, plus it is where I got this code from.