The Stack Data Type

stack is a data type used to store a collection of items and which has the following properties:
  • Elements can be added to the stack 
  • Elements can be removed from the stack, but only in the reverse order from the order in which they were added
Adding an item is known as a Push operation.  Removing an item is known as a Pop operation.
You can think of a stack data type as being like a physical stack of trays.  You can add new trays, but only to the top of the pile (a Push).  You can remove a tray from the stack, but only from the top of the stack (a Pop).
Like a physical stack of trays, we refer to the location of the last item added to the stack as the top of the stack.
A stack is also known as a LIFO (Last-In, First-Out) structure.
842-001