What is Stack ?

( tap to know )

Stack is an abstract data type with a bounded(predefined) capacity. It is a simple data structure that allows adding and removing elements in a particular order. Every time an element is added, it goes on the top of the stack and the only element that can be removed is the element that is at the top of the stack, just like a pile of objects.

  • Stack is a LIFO(Last in First out) structure or we can say FILO(First in Last out).

  • push() function is used to insert new elements into the Stack and pop() function is used to remove an element from the stack. Both insertion and removal are allowed at only one end of Stack called Top.

  • Stack is said to be in Overflow state when it is completely full and is said to be in Underflow state if it is completely empty.

A Real World Example :

  • Compiler Uses Stack To Detect The Brackets Is Correct.
  • A Deck Of Cards.

Stack may Look Like This :