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 the end of the Queue and deleted from the beginning of a queue.

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

It provides different operations or methods to work with Queue

The queue can be implemented using Array or LinkedList

Queue Operations

The queue contains the following basic operations

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

Stack vs Queue

StackQueue
Last In First OutFirst In First Out
Linear Data structureLinear Data structure
Add and delete elements from the top of a listAdd and delete elements from both sides. Adds elements to rear list, Delete an element from the Front of a list
Add an element to Stack called PushAdd an element to Queue called Enqueue
Removes an element from a stack called PopRemoves an element is called Dequeue
Recursion used for Data storagesequential processing for data process