What is Queue data structure

A Queue is a Linear data structure, used to store the data effectively and efficiently.

It follows First in First Out(FIFO). Elements are inserted at end of Queue and deleted from beginning of an queue.

Queue stores different type of the Elements such as strings,integers etc.

It provides different operations or methods to work with Queue

Queue can be implemented using Array or LinkedList

Queue Operations

Queue contains following basic operations

  • push : Adds an element to an Stack
  • pop : Removes an element from an stack
  • top : Returns the top element of an stack
  • isEmpty : true, if stack is empty, false if stack is not empty
  • size : Returns the size of an elements

Stack vs Queue

Stack   Queue  
Last In First Out First In First Out
Linear Data structure Linear Data structure
Add and delete elements from top of an list Add and delete elements from both sides. Adds an elements to rear list, Delete an element from Front of an list
Add an element to Stack called Push Add an element to Queue called Enqueue
Removes an element from a stack called Pop Removes an element is called Dequeue
Recursion used for Data storage sequential processing for data process