0% found this document useful (0 votes)
45 views

Types of Queue in Data Structure

There are four main types of queues in data structures: 1. Simple Queue - elements are inserted at the front and removed from the rear 2. Circular Queue - the last node connects to the first node, elements are inserted at the front and removed from the rear 3. Priority Queue - elements have priorities and the lowest priority element is removed first 4. Dequeue (Double Ended Queue) - allows insertion and removal from both the front and rear. The basic queue operations are enqueue, which adds an element to the front, and dequeue, which removes an element from the rear. Elements are processed in FIFO (First In First Out) order.

Uploaded by

Umamaheswari K
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views

Types of Queue in Data Structure

There are four main types of queues in data structures: 1. Simple Queue - elements are inserted at the front and removed from the rear 2. Circular Queue - the last node connects to the first node, elements are inserted at the front and removed from the rear 3. Priority Queue - elements have priorities and the lowest priority element is removed first 4. Dequeue (Double Ended Queue) - allows insertion and removal from both the front and rear. The basic queue operations are enqueue, which adds an element to the front, and dequeue, which removes an element from the rear. Elements are processed in FIFO (First In First Out) order.

Uploaded by

Umamaheswari K
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Types of Queue in Data structure | Queue

Data structure Introduction and Operations


Queue is an abstract data structure that is similar to stacks. Unlike stacks, a queue is
open at both ends. One end is always used to insert data (enqueue) and the other
end to remove data (dequeue).
 
What is a queue?

A Queue is a FIFO (First In First Out) data structure where the element that is added
first will be deleted first. The basic queue
operations are enqueue (insertion) and dequeue (deletion). Enqueue is done at
the front of the queue and dequeue is done at the end of the queue. The elements
in a queue are arranged sequentially and hence queues are said to be linear data
structures.

The practical examples of queues are

 The consumer who comes first to a shop will be served first. 


 CPU task scheduling and disk scheduling.
 Waiting list of tickets in case of bus and train tickets.

 
Types of Queues in Data Structure

Queue in data structure is of the following types

1. Simple Queue
2. Circular Queue
3. Priority Queue
4. Dequeue (Double Ended Queue)
Simple Queue

The simple queue is a normal queue where insertion takes place at the FRONT of
the queue and deletion takes place at the END of the queue.

Circular Queue
 In a circular queue, the last node is connected to the first node.
 Circular queue is also called as Ring Buffer.
 Insertion in a circular queue happens at the FRONT and deletion at
the END of the queue.

Priority Queue
 In a priority queue, the nodes will have some predefined priority.
 Insertion in a priority queue is performed in the order of arrival of the nodes.
 The node having the least priority will be the first to be removed from the
priority queue.

Dequeue (Doubly Ended Queue)

In a Double Ended Queue, insertion and deletion operations can be done at


both FRONT and END of the queue.
 

Basic operations in a queue

The most basic queue operations in data structure are the following

 enqueue() - Adds an element at the beginning of the queue. If the queue is


full, then it is an overflow.
 dequeue() - Deletes an element at the end of the queue. If the queue is
empty, then it is an underflow.

 
enqueue() 

1. Check if the queue is full.


2. If the queue is full, then print "Queue overflow".
3. Else increment REAR by 1.
4. Assign QUEUE [ REAR ] = ELEMENT.

 
dequeue()

1. Check if the queue is empty.


2. If the queue is empty, the print "Queue underflow".
3. Copy the element at the front of the queue to some temporary
variable, TEMP = QUEUE[ FRONT ].
4. Increment FRONT by 1. 
5. Print temp and delete it.

You might also like