Skip to main content

Command Palette

Search for a command to run...

Recursion - Day 2

Updated
2 min read

Day 2 of my journey into the world of recursion was just as exciting as the first. I continued to explore this powerful technique, diving deeper into the concept and discovering new ways to use it in our coding.

One of the main takeaways from today's session was the importance of understanding base cases. In recursion, a base case is a point at which the function stops calling itself and returns a value. Without a base case, the function will continue to call itself infinitely, causing a stack overflow error.

I also learned about the concept of tail recursion. This is a special case of recursion where the recursive call is the last thing that happens in the function. In tail recursion, the recursive call can be optimized by the compiler to reduce the amount of stack space used, making it more efficient.

One of the most exciting parts of today's session was applying recursion to solve complex problems. And, then I tried to write a function that would find the Fibonacci series for a given number using recursion. This problem requires to use of multiple recursive calls to calculate the previous two numbers in the sequence, and then add them together to get the current number. It was a great exercise in breaking down a complex problem into smaller, more manageable pieces.

Overall, day 2 of our journey into recursion was a huge success. I can't wait to see what tomorrow brings as I continue to explore the power of recursion.

More from this blog

Asritha's Blog

40 posts