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
- Recursion is when a function calls itself
- Every recursive function has 2 cases:
- the base case– the function completes executing and
- the recursive case– the function calls itself
- 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