Consider that you are doing grocery shopping, and you have one of those amazon basic carts to carry your stuff home.
Now we modify the cart in such a way that you can only store items vertically, one on top of each other.This is known as a stack.
You can put items in it, but the first one you put will be last one to take out, because obviously it will be in bottom of the stack. This is called FILO or First in Last out.
Now, Imagine a situation, where there is not space in the cart and you are trying to put items in it. This is stack overflow.
In reality you can feel the stack because you can see it so you know yourself that it is full, half or otherwise empty.
In computer science, stack(the cart) is represented by memory, and the items are nothing but instructions that your program wants processor to perform. Because ultimately processor is going to perform.
Stack overflow is a disastrous error in computing that happens when your program is writing constantly and continuously to the memory, something like recursion – where a section of code is capable of calling itself.
Basically, you cannot feel the memory (stack) like in case of your cart, so you don’t know whether it is full, half or empty.
Latest Answers