Types of Queues | Programming and Data Structures - Computer Science Engineering (CSE) PDF Download

In this tutorial, you will learn different types of queues with along with illustration.
A queue is a useful data structure in programming. It is similar to the ticket queue outside a cinema hall, where the first person entering the queue is the first person who gets the ticket.
There are four different types of queues:

  • Simple Queue
  • Circular Queue
  • Priority Queue
  • Double Ended Queue

1. Simple Queue

In a simple queue, insertion takes place at the rear and removal occurs at the front. It strictly follows the FIFO (First in First out) rule.
Simple Queue RepresentationSimple Queue Representation

2. Circular Queue

In a circular queue, the last element points to the first element making a circular link.

Circular Queue RepresentationCircular Queue RepresentationThe main advantage of a circular queue over a simple queue is better memory utilization. If the last position is full and the first position is empty, we can insert an element in the first position. This action is not possible in a simple queue.

3. Priority Queue

A priority queue is a special type of queue in which each element is associated with a priority and is served according to its priority. If elements with the same priority occur, they are served according to their order in the queue.

Priority Queue RepresentationPriority Queue Representation

Insertion occurs based on the arrival of the values and removal occurs based on priority.

4. Deque (Double Ended Queue)

In a double ended queue, insertion and removal of elements can be performed from either from the front or rear. Thus, it does not follow the FIFO (First In First Out) rule.
Deque RepresentationDeque Representation


The document Types of Queues | Programming and Data Structures - Computer Science Engineering (CSE) is a part of the Computer Science Engineering (CSE) Course Programming and Data Structures.
All you need of Computer Science Engineering (CSE) at this link: Computer Science Engineering (CSE)
119 docs|30 tests

Top Courses for Computer Science Engineering (CSE)

FAQs on Types of Queues - Programming and Data Structures - Computer Science Engineering (CSE)

1. What is a queue in the context of computer science?
A queue is a linear data structure that follows the First-In-First-Out (FIFO) principle. It represents a collection of elements in which elements are added at one end called the rear and removed from the other end called the front. In other words, the element that is inserted first is the first one to be removed.
2. How is a queue different from a stack?
A queue and a stack are both linear data structures, but they differ in terms of the order in which elements are accessed. In a queue, elements are accessed in a First-In-First-Out (FIFO) order, while in a stack, elements are accessed in a Last-In-First-Out (LIFO) order. This means that the element that is inserted last is the first one to be removed in a stack.
3. What are some real-life examples of queues?
Queues can be found in various real-life scenarios. Some examples include waiting in line at a ticket counter, waiting for a bus, or waiting for your turn at a customer service desk. In all these cases, the person who arrives first is served first, following the FIFO principle of a queue.
4. How are queues implemented in computer programming?
Queues can be implemented using arrays or linked lists. In the array implementation, a fixed-size array is used to store the elements of the queue, and two pointers called "front" and "rear" are used to keep track of the positions of the first and last elements. In the linked list implementation, each element of the queue is represented by a node that contains the element value and a pointer to the next node.
5. What are the applications of queues in computer science?
Queues have various applications in computer science. Some examples include process scheduling in operating systems, handling requests in web servers, implementing breadth-first search algorithms, and simulating real-world scenarios like traffic flow or customer service queues. Queues provide an efficient way to manage and process data in a sequential manner.
119 docs|30 tests
Download as PDF
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev
Related Searches

study material

,

pdf

,

Free

,

ppt

,

shortcuts and tricks

,

video lectures

,

Types of Queues | Programming and Data Structures - Computer Science Engineering (CSE)

,

Viva Questions

,

past year papers

,

Objective type Questions

,

Extra Questions

,

mock tests for examination

,

Sample Paper

,

Important questions

,

practice quizzes

,

Types of Queues | Programming and Data Structures - Computer Science Engineering (CSE)

,

Summary

,

Types of Queues | Programming and Data Structures - Computer Science Engineering (CSE)

,

Previous Year Questions with Solutions

,

Exam

,

MCQs

,

Semester Notes

;