0% found this document useful (0 votes)
18 views3 pages

Module 3 Queue Assignment Clean

The document outlines four main types of queues: Linear Queue, Circular Queue, Priority Queue, and Deque, each with distinct characteristics and limitations. It provides algorithms for insertion and deletion in a Circular Queue using an array, along with an example. Additionally, it lists various applications of queues, including CPU scheduling and printer spooling.

Uploaded by

xlucifer585
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views3 pages

Module 3 Queue Assignment Clean

The document outlines four main types of queues: Linear Queue, Circular Queue, Priority Queue, and Deque, each with distinct characteristics and limitations. It provides algorithms for insertion and deletion in a Circular Queue using an array, along with an example. Additionally, it lists various applications of queues, including CPU scheduling and printer spooling.

Uploaded by

xlucifer585
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

MODULE 3 – QUEUE ASSIGNMENT

Q1) Types of Queues

A Queue is a linear data structure that follows the FIFO (First In First Out) principle. There are four
main types of queues:

• 1) Linear Queue: Insertion is done at the rear end and deletion at the front end. It follows FIFO
strictly. Limitation: memory wastage after deletion.

• 2) Circular Queue: The last position is connected to the first position to form a circle. It
overcomes the memory wastage problem of linear queue.

• 3) Priority Queue: Each element has a priority. Elements are removed based on priority rather
than FIFO order.

• 4) Deque (Double Ended Queue): Insertion and deletion can be done from both front and rear
ends. Types include Input Restricted Deque and Output Restricted Deque.
Q2) Circular Queue using Array

Algorithm for Insertion (Enqueue):


• Step 1: If (rear + 1) % size == front, then Queue is Full (Overflow condition).

• Step 2: If front == -1, then set front = rear = 0.

• Step 3: Else set rear = (rear + 1) % size.

• Step 4: Insert the element at queue[rear].

Algorithm for Deletion (Dequeue):


• Step 1: If front == -1, then Queue is Empty (Underflow condition).

• Step 2: Store the value at queue[front].

• Step 3: If front == rear, then set front = rear = -1.

• Step 4: Else set front = (front + 1) % size.

Example (Queue Size = 5):

Index 0 1 2 3 4
Value 10 20 30

After one Dequeue operation, element 10 is removed and front moves to index 1.
Q3) Applications of Queue

• 1) CPU Scheduling in operating systems.

• 2) Printer Spooling systems.

• 3) Breadth First Search (BFS) in Graphs.

• 4) Call Center and Customer Support systems.

• 5) Interrupt handling in real-time systems.

You might also like