Stack Visualization



Start your Stack, Add Elements using Push



OVERVIEW


A Stack is a linear data structure that follows a particular order in which the operations are performed. The order may be LIFO(Last In First Out) or FILO(First In Last Out). LIFO implies that the element that is inserted last, comes out first and FILO implies that the element that is inserted first, comes out last.

Operations


  • push() to insert an element into the stack
  • pop() to remove an element from the stack
  • top() Returns the top element of the stack.
  • isEmpty() returns true if stack is empty else false.
  • size() returns the number of elements currently present in stack.

Key Points


  • It is called as stack because it behaves like a real-world stack, piles of books, etc.
  • A Stack is an abstract data type with a pre-defined capacity, which means that it can store the elements of a limited size.
  • It is a data structure that follows some order to insert and delete the elements, and that order can be LIFO or FILO.
  • Elements in a stack follow a vertically linear arrangement
  • Visualizing a physical stack of objects helps grasp the concept