What Is Tail Recursion?

mainProgrammers deal with recursion all the time. It’s actually quite a nice concept, but not a lot of people use it because of the mystery associated with it. To be honest, there’s no mystery as such! Sometimes, a problem is too complex to solve because it is too big. If we can break the problem down into smaller versions of itself, we may be able to find a way to solve one of these smaller versions and then be able to build up to a solution to the entire problem. This is the entire idea behind recursion. Recursive algorithms break down a problem into smaller pieces which you already know the answer to. We can solve these smaller problems by applying the same algorithm to each piece, and then combine the results. I have discussed all this in complete detail here. Now that we have talked about recursion, what exactly is the title of this blog post referring to? What exactly is tail recursion and why do we need it?   Continue reading “What Is Tail Recursion?”

How To Deal With Buffer Overflow

1 mainYou must have encountered the word ‘buffer’ somewhere in your life. In everyday usage, buffer refers to something that acts as an intermediary between two things that don’t get along. It’s a shield which moderates the impact of one thing over the other. In the programming world, buffer refers to an area where we temporarily store data before moving it to another place. Perhaps the most famous example would be copy-paste. When you copy something, it is stored in the buffer until you paste it somewhere. This concept is used extensively while building software systems and it’s important to make sure that the buffer behaves nicely at all times. Now you might ask, what does buffer behavior refer to? Why would it not behave nicely at all times?   Continue reading “How To Deal With Buffer Overflow”

Understanding Recursion: Part 4/4

mainIn the previous posts, we understood the basics of recursion, we discussed what happens when a recursive call is made and we saw some recursive code. But all that was from a programmer’s perspective. We looked at how we would see it. In this post, we will talk about about recursion from a machine’s perspective. We will see what happens inside when a recursive call is made. Don’t worry if you are not a hardcore coder, we will not be using too much jargon here. You will still be able to understand what we are about to discuss.   Continue reading “Understanding Recursion: Part 4/4”

Understanding Recursion: Part 3/4

recursive treeIn the previous post, we discussed about how we can deconstruct a programming problem to use recursion to our advantage. We will continue to discuss about programming in this post as well. If you are not prepared to look at code, you may want to skip this post and proceed to the next one in the series. If not, continue reading! Let’s continue to talk about trees then. By now, you understand enough about trees for me to not discuss the basics. If you want a refresher on trees, please read my previous post. In this post, we will look at some common recursive programming problems. You will see the problem and the recursive code to solve it, but not the explanation. We have already discussed how to understand a recursive function in full depth. It’s up to you to understand what’s happening inside these functions here.   Continue reading “Understanding Recursion: Part 3/4”

Understanding Recursion: Part 2/4

programming kidIn the previous post, we discussed about the general nature of recursion and recursive programming. We looked at a simple piece of code to understand how recursion happens under the hood. This post delves a bit deeper into recursive programming. Now that we understand recursion, how do we apply it to a real programming problem? We need to understand how we can deconstruct a programming problem so that we can use recursion. Figuring this part out can get tricky sometimes! It’s easier for some problems, but not so much for a few others. In this post, we will look at an abstract data type and see how we use recursion to our advantage. Let’s get out hands dirty, shall we?   Continue reading “Understanding Recursion: Part 2/4”

Understanding Recursion: Part 1/4

part 1Remember the initial days when you were forced to learn recursive programming? And how you were thankful that it’s all over and you don’t have to deal with the whole thing anymore? Well, why do you think that is? Recursion is not all that bad! A lot of beginners who start out with programming somehow end up hating recursion. The main reason is that people don’t really understand how to deconstruct a given problem to make it suitable for recursion. Recursive code, by itself, is nice and small. But understanding what exactly is the recursive part can be pretty confusing. If used correctly, recursion can be one of the best weapons in your programming arsenal. Let’s see what’s beneath all this!   Continue reading “Understanding Recursion: Part 1/4”