Stack

Stack is a kind of data structure that insertions and deletions only performed at the top of its structure. It is LIFO by design which is in contrast with Queue. It could be implemented in list# or array#.

Stack can be used for:

  • balancing symbols
  • postfix expressions which could result in O(N)
  • infix to postfix conversion which could result in O(N)
  • function call

Attention

  • Push, the insertion on Stack, need to detect out of space as an implementation error
  • Pop, the deletion on Stack, and Top, to view most recently inserted element need to detect empty stack as an ADT error
Links to this page
#data-structure #stack