Topics: Data Structure


A stack is a linear data structure in which we can only operate through one end (i.e. we can only insert or delete elements from one of its sides).

The elements in a stack are deleted in the order in which they were inserted; this is why stacks are also called LIFO-type structures (last in, first out).

Like lists, stacks can be contiguous or linked. Stacks have the following operations:

  1. Iteration through the stack
  2. Element insertion (push)
  3. Element deletion (pop)
  4. Element search