What is a stack?

A stack is a LIFO data structure.

It supports 3 constant-time operations, which are very easy to implement using an array.

  • push(x): inserts x into the stack
  • pop(): removes the newest item
  • top(): returns the newest item

#sapling