Circular Queue

A Circular Queue is an extended version of a normal queue where the last element of the queue is connected to the first element of the queue forming a circle. The operations are performed based on FIFO (First In First Out) principle. It is also called ‘Ring Buffer’

Operations on Circular Queue:

  • Front: Get the front item from the queue. Accessing the front element has O(1) time complexity.
  • Rear: Get the last item from the queue. Accessing the rear element has O(1) time complexity.
  • enQueue(value): This function is used to insert an element into the circular queue. In a circular queue, the new element is always inserted at the rear position. 
    • Check whether the queue is full – [i.e., the rear end is in just before the front end in a circular manner].
    • If it is full then display Queue is full, else insert an element at the end of the queue.
    • The time complexity is O(1).
  • deQueue(): This function is used to delete an element from the circular queue. In a circular queue, the element is always deleted from the front position. 
    • Check whether the queue is Empty.
    • If it is empty, then display Queue is empty, else get the last element and remove it from the queue.
    • The Time Complexity is O(1).

Applications of Circular Queue:

  • In a page replacement algorithm, a circular list of pages is maintained and when a page needs to be replaced, the page in the front of the queue will be chosen.
  • Computer systems supply a holding area for maintaining communication between two processes or two programs. This memory area is also known as a ring buffer.
  • CPU Scheduling: In the Round-Robin scheduling algorithm, a circular queue is utilized to maintain processes that are in a ready state.

Queue Notes for GATE Exam [2024]

A Queue is defined as a linear data structure that is open at both ends and the operations are performed in First In First Out (FIFO) order. Queue is a list in which all additions to the list are made at one end, and all deletions from the list are made at the other end.  The element, which is first pushed into the order, the operation is first performed on that.

FIFO Property in Queue

Table of Content

  • Implementing Queues using Arrays:
  • Implementing Queues using Linked List:
  • Implementation of Queue using Stack:
  • Circular Queue:
  • Priority Queue:
  • Double Ended Queue:
  • GATE Archives – Previous Years Questions on Queue:

Similar Reads

Implementing Queues using Arrays:

To implement a queue using an array,...

Implementing Queues using Linked List:

To implement a queue using a Linked List,...

Implementation of Queue using Stack:

...

Circular Queue:

A Circular Queue is an extended version of a normal queue where the last element of the queue is connected to the first element of the queue forming a circle. The operations are performed based on FIFO (First In First Out) principle. It is also called ‘Ring Buffer’....

Priority Queue:

A priority queue is a type of queue that arranges elements based on their priority values. Elements with higher priority values are typically retrieved before elements with lower priority values.If we add an element with a high priority value to a priority queue, it may be inserted near the front of the queue, while an element with a low priority value may be inserted near the back....

Double Ended Queue:

Deque or Double Ended Queue is a generalized version of Queue data structure that allows insert and delete at both ends....

GATE Archives – Previous Years Questions on Queue:

Q1. Following is C like pseudo-code of a function that takes a Queue as an argument, and uses a stack S to do processing....

Contact Us