Queue Data Structure (original) (raw)

Last Updated : 17 Sep, 2025

Queueis a linear data structure that follows FIFO (First In First Out) Principle, so the first element inserted is the first to be popped out.

**FIFO Principle in Queue:

FIFO Principle states that the first element added to the Queue will be the first one to be removed or processed. So, Queue is like a line of people waiting to purchase tickets, where the first person in line is the first person served. (i.e. First Come First Serve).

Dequeue-Operation-in-Queue-1

Basic Terminologies of Queue

**Types of Queues

Queue data structure can be classified into 3 types:

Types-of-Queue

1. Simple Queue

A simple queue follows the FIFO (First In, First Out) principle.

When an array is used, we often prefer a **circular queue, which is mainly an efficient array implementation of a simple queue. It efficiently utilizes memory by reusing the empty spaces left after deletion, avoiding wastage that occurs in a normal linear array implementation..

2. Double-Ended Queue (Deque)

In a deque, insertion and deletion can be performed from both ends.

3. Priority Queue

A queue where each element is assigned a **priority, and deletion always happens based on priority (not just position).

Queue Operations

  1. **Enqueue: Adds an element to the end (rear) of the queue. If the queue is full, an overflow error occurs.
  2. **Dequeue: Removes the element from the front of the queue. If the queue is empty, an underflow error occurs.
  3. **Peek/Front: Returns the element at the front without removing it.
  4. **Size: Returns the number of elements in the queue.
  5. **isEmpty: Returns true if the queue is empty, otherwise false.
  6. **isFull: Returns true if the queue is full, otherwise false.

For detailed steps and more information on each operation, Read Basic Operations for Queue in Data Structure.

Implementation of Queue

Queue can be implemented using following data structures:

Application of Queue

Applications-of-Queue

Advantages of Queue

Advantages-of-Queue

Queue Data Structure

Application of Queue Data structure