Stack is the other common linear data structure which is been used now a days. Just like we did with the ordered list, we will examine the abstract view of the stack first and then look at the couple of ways a stack can be implemented.
A D V E R T I S E M E N T
Stack is very similar to a list except that a stack is more restricted. The figure below should give you an good idea of the abstract view of what stack is. Follow the directions to manipulate the simple stack and learn about the operations that the stack provides.
By seing the figure above you can see that this data structure is really a restricted list. You have restricted the access to one end of the list by using the pop and push operations. The result of this restriction is that items in the list will be stored one on top of the other. We must first remove all the items above it till you get to the bottom item. "Last-In, First-Out" or LIFO, which is used to describe the behavior, since the last item to enter the stack is the first item to leave the stack. The top item is the item always the last item to enter the stack and it is always the first item to leave the stack since no other items can be removed until the top item is removed.