Conceptually a stack is similar to a stack of plates. When a plate is added it is added to the top of the stack. When a plate is taken from the stack it is grabbed from the top of the stack. A stack data structure works like a virtual version of a stack of plates. Elements are added to the top of the stack. Removing an element from the stack gets the last element that was added to the stack. A stack is often referred to as last in first out (LIFO). This refers to the order in which elements are added and removed from a stack.
Here’s an image depicting what adding an element to a stack looks like conceptually:
Here’s an image depicting what removing an element from a stack looks like conceptually:
Advantages:
Disadvantages: