What is Stack?
In computer science, a stack is an abstract data type that serves as a collection of elements, with two principal operations: push, which adds an element to the collection, and. pop, which removes the most recently added element that was not yet removed.
Consider a stack of chairs as shown in the picture below. Here, the chairs the kept one on the other which shows that when you add a new chair (push) you should place it at the top of the stack and when you need to take, you should take (pop) it from the top. If you need to take the fifth chair from the top, you are supposed to take out the first four chairs and you get your fifth chair. This makes true for the statement, “You take the chair which you placed most recently” otherwise, First In Last Out (FILO) or Last In First Out (LIFO). This concept is implemented in the data structure where the values can be placed in this order if we need.
More on implementation on a Stack
Stack has memory whenever implemented in a program. When the memory of the values pushes into a stack gets collectively more than the memory of the stack then the problem occurs as Stack Overflow. If n values stored in the stack get popped from it and when popping the non-existing (n+1)th value then the problem occurs as Stack Underflow.
Implementation of Stack in Python
self.items = 
def push(self, item):
Like and Follow this blog. Support our Facebook page. Feel free to contact us for your queries. Mail us your queries to firstname.lastname@example.org
Maria Irudaya Regilan J