DEV Community

Jasterix
Jasterix

Posted on

Grokking Algorithms – Recursions

Part of being a JavaScript ninja is being somewhat proficient at tackling algorithms or what I've been calling "bite-sized trickery".

As a relative beginner, I've been coming across what seems like the same 10 problems in different shapes, colors and sizes a.k.a varying levels of difficulty.

Struggling to solve this problem for 4 hours made me realize that when it came to algorithms, I had no idea where to begin. While Flatiron gave me great set of fundamental tools, these tools or rather, how I'm used to applying them, aren't always the the best fit for solving LeetCode problems.

So I decided to pick up Grokking Algorithms by Aditya Bhargava. This book has been recommended to me a few times, but I initially chose to learn by doing, which was less than successful.

Still, ever the rebel, I decided to start with chapter 3: recursions.

Here are my 3 takeaways on recursions

  1. Recursion is when a function calls itself
  2. Every recursive function has 2 cases:
    1. the base case– the function completes executing and
    2. the recursive case– the function calls itself
  3. This means that while each function call goes onto the call stack, those function calls don't complete until the base case is met

Check out Grokking Algorithms at your local library or on Amazon

Top comments (0)