Recursion in Programming – Full Course

Ecommerce Empire Academy

Recursion is a powerful technique that helps us bridge the gap between complex problems being solved with elegant code. Within this course, we will break down what recursion is, why you would and wouldn’t want to use it and look at a variety of examples for how it can be used.

We’ll break down recursion with all sorts of data-structures, animations, debugging and call-stack analysis to get a deeper understanding to these principles.

The code is written in Java, but the principles are agnostic to any language.

✏️ This course was developed by The Simple Engineer. Find him online:

⭐️ Course Contents ⭐️
⌨️ (0:00:00) Introduction
⌨️ (0:00:42) What Is Recursion?
⌨️ (0:00:50) Explaining Recursion via ATM Analogy
⌨️ (0:04:56) Explaining Recursion via Essay Revision Analogy
⌨️ (0:06:22) Summarizing What Recursion Is
⌨️ (0:07:15) Why & Why Not Recursion
⌨️ (0:10:57) Understanding The Call Stack
⌨️ (0:11:32) Call Stack Analogy
⌨️ (0:16:35) Recursion With Strings Introduction
⌨️ (0:16:50) String Reversal Explanation
⌨️ (0:20:47) String Reversal Call Stack Animation
⌨️ (0:22:59) Palindrome Explanation
⌨️ (0:25:46) Palindrome Call Stack Animation
⌨️ (0:27:46) Recursion With Numbers
⌨️ (0:28:02) Decimal To Binary Explanation
⌨️ (0:31:12) Decimal To Binary Code & Debug
⌨️ (0:34:33) Sum of Natural Numbers Explanation
⌨️ (0:36:17) Sum of Natural Numbers Code & Debug
⌨️ (0:38:51) Divide & Conquer Algorithms
⌨️ (0:39:27) Binary Search Animation & Explanation
⌨️ (0:43:50) Fibonacci Explanation
⌨️ (0:45:54) Fibonacci Animation
⌨️ (0:49:07) Merge Sort Explanation & Animation
⌨️ (0:53:21) Merge Sort Code & Debug
⌨️ (1:09:36) Linked Lists
⌨️ (1:09:49) Linked List Reversal Animation
⌨️ (1:14:48) Linked List Code & Debug
⌨️ (1:19:52) Merge Two Sorted Linked Lists Animation
⌨️ (1:25:53) Merge Two Sorted Linked Lists Code & Debug
⌨️ (1:29:02) Trees
⌨️ (1:29:14) Insert Value Into Binary Search Tree Animation
⌨️ (1:31:32) Insert Value Into Binary Search Tree Code Walkthrough
⌨️ (1:33:43) Insert Value Into Binary Search Tree Call Stack Animation
⌨️ (1:35:11) Print All Leaf Nodes Explanation
⌨️ (1:37:02) Print All Leaf Nodes Code & Debug
⌨️ (1:41:09) Graphs
⌨️ (1:41:21) Depth-First Search Animation
⌨️ (1:42:58) Depth-First Search Code Walkthrough
⌨️ (1:45:38) Recursion Optimizations
⌨️ (1:45:44) Memoization & Caching
⌨️ (1:47:59) Tail-Call Recursion
⌨️ (1:50:48) Conclusion

🎉 Thanks to our Champion and Sponsor supporters:
👾 Wong Voon jinq
👾 hexploitation
👾 Katia Moran
👾 BlckPhantom
👾 Nick Raker
👾 Otis Morgan
👾 DeezMaster
👾 Treehouse
👾 AppWrite

Learn to code for free and get a developer job:

Read hundreds of articles on programming:

And subscribe for new videos on technology every day:

31 thoughts on “Recursion in Programming – Full Course”

  1. Hey everyone! 👋. I’m stoked to share some knowledge on recursion through FCC. Feel free to reach out or connect with me if you have questions!

    1. thobias larsen

      Thank you soo much! This is just what I needed to more clearly understand recursion and dynamic programming for my competetive programming! Wonderful resource

  2. Sanuja Methmal

    Thanks a lot. These kind of videos are so rare. Please consider more videos on functional programming design patterns

  3. Thank you so much for the video. This is the best explanation I’ve got on recursion after several books and YouTube videos. The analogy where people were waiting in a queue (for ATM) is in my view what set my mind free on how to go about recursion. Now I know how and why a problem is attacked recursively.
    Cheers from me!

  4. Man thank you so much for your explanations of how recursive calls work on the call stack, and then also how to interpret the call stack through debugging. This cleared up so much confusion for me!

  5. Snehashish Ghosh

    The way in which the lecture has been made is awesome… From the smallest of concepts to advanced concepts. I enjoyed learning.

  6. Amazing!!! please do more videos like this. These kinds of videos help to strengthen problem-solving skills.
    Next topic suggestion -> iterative solution and tabulation

  7. The iterative solutions was going through my mind for all the problems here except the graphs problems. Understood the concept of recursion, well explained.

  8. I feel like the first 5 minutes of this video helped me understand recursion better than my CS classes in college. I ended up switching tracks away from CS because I couldn’t wrap my head around recursion and trees…

    1. You cannot understand trees or graphs without recursion. It takes some practice, but becomes quite intuitive once you wrap your head around it.

  9. Like many other comments, the simplistic breakdowns of recursion in this video help make sense of this topic for even the most confused. I thoroughly enjoyed this video and wish this could get bumped up for more of the world to see!

  10. Shankar Ghimire

    Thank you so much Ryan for sharing your knowledge with the world!
    Very amazing content and explanation! 🙂

  11. Thanks for this explanation of recursion. I finally understood recursion the way I should and how to use it. Good examples👍

  12. Jean-Francois Desrosiers

    Been coding since 1997: recursion is good for academic purposes but almost everytime I saw it in a product, it was a source of bugs due to usage of stack above limits, which limits are very difficult to guess. Each f call is on stack.

    1. There are definitely trade-offs. In some of my professional work, we’ve dealt with data structures that are tree and graph-based (ie. graph databases and the algorithms that need to be built around the data) where traversals are inherently more elegant and easily understood via recursion, whereas the iterative counterpart is a mess and often impossible to conceptualize with loops. The risk is memory, but when the bounds are understood, you can make an informed decision more appropriately. This is also true with a lot of taxonomy work when you’re dealing with schemas, for example (trees).

    2. I would suggest not to simply nullify the topic. Yes, you won’t use it much but it’s great for concept building. FYI, I recently used Recursion in my project. I was bulding a component to show hierarchy using Tree-grid.

    3. I tried using the decimal to Binary example at 31:14 in a for loop and in the recursion way he showed, and tried to use the function for big numbers like pow (99, 99), it worked but recursion executed 3 times slower than the for loop, and increasing the number, to pow(99,150) I get a stack error.
      So, I won’t use this at my work at all. Only in case I might need to use with something related to graph.

    4. Ryan Schachte

      @Julio Lopes Definitely good to evaluate why and when it’s a good choice to use it. 3x slower on modern day systems for small amounts of data is negligible. Think 5 nanoseconds vs 15 nanoseconds. However, on large datasets, recursion will of course be slower. Cheers! Nice work on investigating the performance.

  13. Sylvain Brunerie

    All these examples look super interesting, but I just want to point out that tail-call recursion optimization is super important to know, even though it’s kinda briefly mentioned here. Really sad that’s it’s mostly not supported in JS yet. Have a look at Elm if you want to safely use recursion in the browser 🙂

  14. Anime Reviews

    In the beginning when I started learning programming I didn’t think recursion is that much important but when I started to learn DSA. I figured it out recursion is the soul of DSA and now I am learning, I have crossed 1:30 hr video and it has been so much fun and easy to grab. The tutor is really good …

    1. Agreed man, the worst thing I’ve done was trying to attempt tree, graph and linkedlist problems without a complete understanding of recursion.

  15. MYLARAM Venkatesh

    There are no words to praise you about your explanation and content, Really Mind blowing for me, Super content thank you man

  16. Stanley Ogada Chinedu

    I love this guy! Honestly Recursion is the hardest concept in programming (In my opinion!). I have being able to solve the palindrome challenge on my own. I know palindrome is easy but I’m happy I can do this after watching the first few lessons. 🤌🏾❤😂

  17. using relative analogies and debugger to explain call stuck made it easy for me understand,Thanks simple Engineer

  18. Thanks for the content presentend here; very clear, excellent explanation very great examples!

  19. A K M Zahidul Islam

    Just wonderful! A brilliant teacher who is wholeheartedly passionate and industrious about teaching. Result? You watch this.

Comments are closed.