Stack Abstract Data Type

A stack ADT supports two main operations:

  • push which adds an element to the data structure
  • pop which removes the most recently added element that was not yet removed

The order in which elements are removed gives rise to the term LIFO (last in, first out) to describe a stack.

It helps to visualize a stack as an ADT where operations are done on one end of the collection and access to all other positions is restricted.

A stack has a variety of applications such as:

  • function call stack in program execution
  • reversing order of elements
  • undo mechanism (e.g. undo functionality in text editors)
  • evaluating/parsing expressions (e.g. reverse polish notations)
Resources