Stack Abstract Data Type

  • Describe the Stack ADT.

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 think of 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 the order of elements.
  • Undo mechanism (e.g., undo functionality in text editors).
  • Evaluating/parsing expressions (e.g., reverse polish notations).
Resources