Stack (abstract data type)

What is a stack?

In computer science, a stack is an ADT that serves as a collection of elements, with two main operations:

  • Push, which adds an element to the collection, and
  • Pop, which removes the most recently added element that was not yet removed.
    — Wikipedia

Example of stack of layers:

     ____________ precedence
    / LIFO      / | high
31 /___________// |
30 /___________// |
29 /___________/  |
 :   _:_:_:_:_:__ |
 :  / : : : : : / |
 2 /___________// |
 1 /___________// |
 0 /_FILO______/  V low