SlideShare a Scribd company logo
1 of 16
Sourav Mishra
1801353
1
QUEUE
• Queue is the linear data structure type which is
used to organize the data.
• It is used for temporary storage of data values.
• A new element is added at one end called rear
end
• The existing element deleted from the other end
is called front end.
• First-in-First-out property.
2
Type of queue
Simple
Queue
Circular
Queue
Priority
Queue
Dequeue
(Double
ended
Queue)
3
Simple Queue
• Simple queue defines the simple operation of
queue in which insertion occurs at the rear of
the list and deletion occurs at the front of the
list.
4
Circular Queue
• In a circular queue, all nodes are treated as
circular. Last node is connected back to the
first node.
• Circular queue is also called as Ring Buffer.
• It is an abstract data type.
• Circular queue contains a collection of data
which allows insertion of data at the end of the
queue and deletion of data at the beginning of
the queue
5
x
6
Priority Queue
• Priority queue contains
data items which have
some preset priority.
While removing an
element from a priority
queue, the data item with
the highest priority is
removed first.
• In a priority queue,
insertion is performed in
the order of arrival and
deletion is performed
based on the priority.
7
Dequeue
(Double ended Queue)
• In Double Ended Queue, insert and delete
operation can be occur at both ends that is front
and rear of the queue
8
LINEAR
QUEUE
• A linear data structure that
stores data as a sequence of
element similar to a real
world queue.
• Possible to enter new items
from the rear end and
remove the items from the
front.
• Requires more memory.
• Less efficient.
CIRCULAR
QUEUE
• A linear data structure in
which the last item connects
back to the first item
forming a circle.
• Possible to enter and
remove elements from any
position.
• Requires less memory.
• More efficient.
9
Operations on Queue
• Enqueue() − add (store) an item to the queue.
• Dequeue() − remove (access) an item from the
queue.
• peek() − Gets the element at the front of the
queue without removing it.
• isfull() − Checks if the queue is full.
• isempty() − Checks if the queue is empty
10
Enqueue Operation
• Step 1 − Check if the queue
is full.
• Step 2 − If the queue is full,
produce overflow error and
exit.
• Step 3 − If the queue is not
full, increment rear pointer
to point the next empty
space.
• Step 4 − Add data element
to the queue location, where
the rear is pointing.
• Step 5 − return success.
11
Algorithm Of Enqueue
procedure enqueue(data)
if queue is full
return overflow
12
rear ← rear + 1
queue[rear] ← data
return true
end procedure
int enqueue (int data)
if(isfull())
return 0;
rear = rear + 1;
queue[rear] = data;
return 1;
end procedure
Example of
Enqueue
12
Dequeue Operation
• Step 1 − Check if the queue
is empty.
• Step 2 − If the queue is
empty, produce underflow
error and exit.
• Step 3 − If the queue is not
empty, access the data
where front is pointing.
• Step 4 −
Increment front pointer to
point to the next available
data element.
• Step 5 − Return success.
13
Algorithm for
dequeue operation
procedure dequeue
if queue is empty
return underflow
end if
data = queue[front]
front ← front + 1
return true
end procedure
int dequeue()
{
if(isempty())
return 0;
int data = queue[front]; front =
front + 1;
return data;
}
Example of
Dequeue Operation
14
Application of Queue
• Queue is useful in CPU scheduling, Disk
Scheduling.
• When data is transferred asynchronously
between two processes. Queue is used for
synchronization. Examples : IO Buffers, pipes,
file IO, etc.
• In real life, Call Center phone systems will use
Queues, to hold people calling them in an
order, until a service representative is free.
15
llllllj
16

More Related Content

What's hot (20)

SEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMSSEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMS
 
Stack
StackStack
Stack
 
stack & queue
stack & queuestack & queue
stack & queue
 
Array data structure
Array data structureArray data structure
Array data structure
 
linked list in data structure
linked list in data structure linked list in data structure
linked list in data structure
 
Arrays
ArraysArrays
Arrays
 
Data structure & its types
Data structure & its typesData structure & its types
Data structure & its types
 
Stack
StackStack
Stack
 
Linked List
Linked ListLinked List
Linked List
 
Data Structure (Queue)
Data Structure (Queue)Data Structure (Queue)
Data Structure (Queue)
 
Infix to postfix conversion
Infix to postfix conversionInfix to postfix conversion
Infix to postfix conversion
 
Deque and its applications
Deque and its applicationsDeque and its applications
Deque and its applications
 
Queue data structure
Queue data structureQueue data structure
Queue data structure
 
Searching and Sorting Techniques in Data Structure
Searching and Sorting Techniques in Data StructureSearching and Sorting Techniques in Data Structure
Searching and Sorting Techniques in Data Structure
 
Linear search-and-binary-search
Linear search-and-binary-searchLinear search-and-binary-search
Linear search-and-binary-search
 
Graph in data structure
Graph in data structureGraph in data structure
Graph in data structure
 
Introduction to data structure ppt
Introduction to data structure pptIntroduction to data structure ppt
Introduction to data structure ppt
 
List in Python
List in PythonList in Python
List in Python
 
Python list
Python listPython list
Python list
 
Tree - Data Structure
Tree - Data StructureTree - Data Structure
Tree - Data Structure
 

Similar to Queue ppt

Similar to Queue ppt (20)

queueppt-191018053228 (1).pptx
queueppt-191018053228 (1).pptxqueueppt-191018053228 (1).pptx
queueppt-191018053228 (1).pptx
 
Queue AS an ADT (Abstract Data Type)
Queue AS an ADT (Abstract Data Type)Queue AS an ADT (Abstract Data Type)
Queue AS an ADT (Abstract Data Type)
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data Structure
 
@Chapter 4 DSA Part II.pptx
@Chapter 4 DSA Part II.pptx@Chapter 4 DSA Part II.pptx
@Chapter 4 DSA Part II.pptx
 
Queues
Queues Queues
Queues
 
Queue
QueueQueue
Queue
 
Basic Queue Operation in DataStructure.pptx
Basic Queue Operation in DataStructure.pptxBasic Queue Operation in DataStructure.pptx
Basic Queue Operation in DataStructure.pptx
 
queue.pptx
queue.pptxqueue.pptx
queue.pptx
 
Data Structures 2
Data Structures 2Data Structures 2
Data Structures 2
 
Stack and Queue.pptx
Stack and Queue.pptxStack and Queue.pptx
Stack and Queue.pptx
 
LEC4-DS ALGO.pdf
LEC4-DS  ALGO.pdfLEC4-DS  ALGO.pdf
LEC4-DS ALGO.pdf
 
Queue
QueueQueue
Queue
 
Queues
QueuesQueues
Queues
 
Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data Structure
 
Unit-ii-Queue ADT.pptx
Unit-ii-Queue ADT.pptxUnit-ii-Queue ADT.pptx
Unit-ii-Queue ADT.pptx
 
Queue
QueueQueue
Queue
 
Stack and queue
Stack and queueStack and queue
Stack and queue
 
Stack.pptx
Stack.pptxStack.pptx
Stack.pptx
 
Data Structures
Data StructuresData Structures
Data Structures
 

Recently uploaded

CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfAsst.prof M.Gokilavani
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxKartikeyaDwivedi3
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)dollysharma2066
 
DATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage exampleDATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage examplePragyanshuParadkar1
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHC Sai Kiran
 
pipeline in computer architecture design
pipeline in computer architecture  designpipeline in computer architecture  design
pipeline in computer architecture designssuser87fa0c1
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)Dr SOUNDIRARAJ N
 

Recently uploaded (20)

CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptx
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
 
DATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage exampleDATA ANALYTICS PPT definition usage example
DATA ANALYTICS PPT definition usage example
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECH
 
pipeline in computer architecture design
pipeline in computer architecture  designpipeline in computer architecture  design
pipeline in computer architecture design
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 

Queue ppt

  • 2. QUEUE • Queue is the linear data structure type which is used to organize the data. • It is used for temporary storage of data values. • A new element is added at one end called rear end • The existing element deleted from the other end is called front end. • First-in-First-out property. 2
  • 4. Simple Queue • Simple queue defines the simple operation of queue in which insertion occurs at the rear of the list and deletion occurs at the front of the list. 4
  • 5. Circular Queue • In a circular queue, all nodes are treated as circular. Last node is connected back to the first node. • Circular queue is also called as Ring Buffer. • It is an abstract data type. • Circular queue contains a collection of data which allows insertion of data at the end of the queue and deletion of data at the beginning of the queue 5
  • 6. x 6
  • 7. Priority Queue • Priority queue contains data items which have some preset priority. While removing an element from a priority queue, the data item with the highest priority is removed first. • In a priority queue, insertion is performed in the order of arrival and deletion is performed based on the priority. 7
  • 8. Dequeue (Double ended Queue) • In Double Ended Queue, insert and delete operation can be occur at both ends that is front and rear of the queue 8
  • 9. LINEAR QUEUE • A linear data structure that stores data as a sequence of element similar to a real world queue. • Possible to enter new items from the rear end and remove the items from the front. • Requires more memory. • Less efficient. CIRCULAR QUEUE • A linear data structure in which the last item connects back to the first item forming a circle. • Possible to enter and remove elements from any position. • Requires less memory. • More efficient. 9
  • 10. Operations on Queue • Enqueue() − add (store) an item to the queue. • Dequeue() − remove (access) an item from the queue. • peek() − Gets the element at the front of the queue without removing it. • isfull() − Checks if the queue is full. • isempty() − Checks if the queue is empty 10
  • 11. Enqueue Operation • Step 1 − Check if the queue is full. • Step 2 − If the queue is full, produce overflow error and exit. • Step 3 − If the queue is not full, increment rear pointer to point the next empty space. • Step 4 − Add data element to the queue location, where the rear is pointing. • Step 5 − return success. 11
  • 12. Algorithm Of Enqueue procedure enqueue(data) if queue is full return overflow 12 rear ← rear + 1 queue[rear] ← data return true end procedure int enqueue (int data) if(isfull()) return 0; rear = rear + 1; queue[rear] = data; return 1; end procedure Example of Enqueue 12
  • 13. Dequeue Operation • Step 1 − Check if the queue is empty. • Step 2 − If the queue is empty, produce underflow error and exit. • Step 3 − If the queue is not empty, access the data where front is pointing. • Step 4 − Increment front pointer to point to the next available data element. • Step 5 − Return success. 13
  • 14. Algorithm for dequeue operation procedure dequeue if queue is empty return underflow end if data = queue[front] front ← front + 1 return true end procedure int dequeue() { if(isempty()) return 0; int data = queue[front]; front = front + 1; return data; } Example of Dequeue Operation 14
  • 15. Application of Queue • Queue is useful in CPU scheduling, Disk Scheduling. • When data is transferred asynchronously between two processes. Queue is used for synchronization. Examples : IO Buffers, pipes, file IO, etc. • In real life, Call Center phone systems will use Queues, to hold people calling them in an order, until a service representative is free. 15