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

Applications of Queue

Uploaded by

ananyaprakash005
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)
12 views

Applications of Queue

Uploaded by

ananyaprakash005
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
You are on page 1/ 4

Applications of queue

Circular Queue
Circular Queue is a linear data structure in which the operations are performed
based on FIFO (First In First Out) principle and the last position is connected back to
the first position to make a circle. It is also called ‘Ring Buffer’.
In a normal Queue, we can insert elements until queue becomes full. But once
queue becomes full, we can not insert the next element even if there is a space in
front of queue.
1. .

Operations on Circular Queue:


• Front: Get the front item from queue.
• Rear: Get the last item from queue.
• 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 Rear
position.
Steps:
1. Check whether queue is Full – Check ((rear == SIZE-1 && front == 0) ||
(rear == front-1)).
2. If it is full then display Queue is full. If queue is not full then, check if (rear
== SIZE – 1 && front != 0) if it is true then set rear=0 and insert element.
• deQueue() This function is used to delete an element from the circular queue.
In a circular queue, the element is always deleted from front position.
Steps:
1. Check whether queue is Empty means check (front==-1).
2. If it is empty then display Queue is empty. If queue is not empty then step
3
Check if (front==rear) if it is true then set front=rear= -1 else check if (front==size-1),
if it is true then set front=0 and return the element

Deque Data Structure


In this tutorial, you will learn what a double ended queue (deque) is. Also,
you will find working examples of different operations on a deque in C,
C++, Java and Python.

Deque or Double Ended Queue is a type of queue in which insertion and


removal of elements can be performed from either from the front or rear.
Thus, it does not follow FIFO rule (First In First Out).

Representation of Deque

Types of Deque
• Input Restricted Deque
In this deque, input is restricted at a single end but allows deletion at both
the ends.
• Output Restricted Deque
In this deque, output is restricted at a single end but allows insertion at both
the ends.

Priority Queue
In this tutorial, you will learn what priority queue is. Also, you will learn
about it's implementations in Python, Java, C, and C++.
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.

Generally, the value of the element itself is considered for assigning the
priority.

For example, The element with the highest value is considered as the
highest priority element. However, in other cases, we can assume the
element with the lowest value as the highest priority element. In other
cases, we can set priorities according to our needs.

Removing Highest
Priority Element
Difference between Priority Queue and Normal Queue

In a queue, the first-in-first-out rule is implemented whereas, in a priority


queue, the values are removed on the basis of priority. The element with
the highest priority is removed first.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy