SlideShare a Scribd company logo
Introduction.
Operations on Queue.
Array representation of Queue.
Type of Queue
Circular Queue.
Applications of Queue.
A data structure is a particular way of
organizing data in a computer so that it can
be used efficiently.
Different kind of data structure suits for
the different kind of applications.
DATA STRUCTURE
PRIMITIVE DS NON-PRIMITIVE DS
Integers
Character
Float
Linear DS Non-Linear DS
 Tree
 Graph
 Array
 Linked list
 Queue
 Stack
 Queue is a linear data structure.
 It is used for temporary storage of data values.
 A new element is added at one end called rear
end.
 The existing elements deleted from the other end
called front end.
 First-in-First-out property.
45 25 10 52 78 94 20
front
rear
1.Insertion :
Placing an item in a queue is called “insertion
or enqueue”, which is done at the end of the
queue called “rear”.
2.Deletion :
Removing an item from a queue is called
“deletion or dequeue” , which is done at the
other end of the queue called “front”.
12 9 7 18 5
A[0] A[1] A[2] A[3] A[5] A[6]
Queue
rearfront
12 9 7 18 5 14
9 7 18 5 14
Queue after insertion of new element rearfront
Queue after deletion of an element
rearfront
Algorithm:- enqueue
Input:-queue[Max],FRONT,REAR,VALUE
Output:-queue of elements
Begin:-
STEP:1- IF REAR= MAX-1
Print “Queue is OVERFLOW”
Return.
STEP:2- If (FRONT=-1)
FRONT=FRONT+1
STEP:3- REAR = REAR+1
queue[REAR] = VALUE
STEP:4- END.
INITIALLY
REAR = -1
FRONT =-1
Algorithm:- de_queue
Input:- queue[MAX],REAR,FRONT
Output:-deleted data ITEM
Begin:-
Step:1-If (REAR=-1)
Print “Queue is UNDERFLOW”
Return.
Step:2-ITEM=queue[FRONT]
Step:3-If (REAR=FRONT)
{
REAR=FRONT=-1
}
Else
FRONT=FRONT+1
Step:4- print deleted data ITEM
END.
Circular Queue
INTRODUCTION
 Circular queue are used to remove
the drawback of LINEAR queue.
 Last element of the queue is
connected back with first element of
the queue.
 It is also called as “Ring buffer”.
STEP-1 If FRONT = (REAR+1)%MAX
write OVERFLOW
go to step 4
STEP-2 If (REAR=FRONT = -1)
{
REAR = FRONT = +1
}
Else
REAR = (REAR +1)%MAX
STEP-3 CQ[REAR] = NUM
STEP-4 EXIT
STEP-1 If FRONT = -1
write UNDERFLOW
go to step 3
STEP-2 ITEM =c_queue[FRONT]
STEP-3 If (FRONT = REAR)
{
FRONT = REAR= -1
}
Else{
FRONT = (FRONT +1)%MAX
}
STEP-3 EXIT
 Real world applications
 Cashier line in any store.
 Waiting on hold for tech support.
 people on an escalator.
 Checkout at any book store.
“TO MAKE AN END IS TO
MAKE A beginning”.
END OF PRESENTATION
 Thank you for your kind attention.

More Related Content

What's hot

Circular queue
Circular queueCircular queue
My lectures circular queue
My lectures circular queueMy lectures circular queue
My lectures circular queueSenthil Kumar
 
Priority queues and heap sorting
Priority queues and heap sortingPriority queues and heap sorting
Priority queues and heap sorting
heshekik
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data Structure
Lovely Professional University
 
Detalied information of queue
Detalied information of queueDetalied information of queue
Detalied information of queue
Smit Parikh
 
QUEUE IN DATA STRUCTURE USING C
QUEUE IN DATA STRUCTURE USING CQUEUE IN DATA STRUCTURE USING C
QUEUE IN DATA STRUCTURE USING C
Meghaj Mallick
 
Queue implementation
Queue implementationQueue implementation
Queue implementation
Rajendran
 
Queue
QueueQueue
Algorithm: priority queue
Algorithm: priority queueAlgorithm: priority queue
Algorithm: priority queueTareq Hasan
 
Queue
QueueQueue
Unit 4 queue
Unit   4 queueUnit   4 queue
Unit 4 queue
Dabbal Singh Mahara
 
Data Structure (Queue)
Data Structure (Queue)Data Structure (Queue)
Data Structure (Queue)
Adam Mukharil Bachtiar
 
Queue
QueueQueue
Queue
QueueQueue
Queues-and-CQueue-Implementation
Queues-and-CQueue-ImplementationQueues-and-CQueue-Implementation
Queues-and-CQueue-Implementation
shaik faroq
 
Deque and its applications
Deque and its applicationsDeque and its applications
Deque and its applicationsJsaddam Hussain
 
Queue data structure
Queue data structureQueue data structure
Queue data structure
Mekk Mhmd
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data Structure
Zidny Nafan
 
What is Stack, Its Operations, Queue, Circular Queue, Priority Queue
What is Stack, Its Operations, Queue, Circular Queue, Priority QueueWhat is Stack, Its Operations, Queue, Circular Queue, Priority Queue
What is Stack, Its Operations, Queue, Circular Queue, Priority Queue
Balwant Gorad
 

What's hot (20)

Circular queue
Circular queueCircular queue
Circular queue
 
My lectures circular queue
My lectures circular queueMy lectures circular queue
My lectures circular queue
 
Priority queues and heap sorting
Priority queues and heap sortingPriority queues and heap sorting
Priority queues and heap sorting
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data Structure
 
Detalied information of queue
Detalied information of queueDetalied information of queue
Detalied information of queue
 
QUEUE IN DATA STRUCTURE USING C
QUEUE IN DATA STRUCTURE USING CQUEUE IN DATA STRUCTURE USING C
QUEUE IN DATA STRUCTURE USING C
 
Queue implementation
Queue implementationQueue implementation
Queue implementation
 
Queue
QueueQueue
Queue
 
Algorithm: priority queue
Algorithm: priority queueAlgorithm: priority queue
Algorithm: priority queue
 
Queue
QueueQueue
Queue
 
Unit 4 queue
Unit   4 queueUnit   4 queue
Unit 4 queue
 
Data Structure (Queue)
Data Structure (Queue)Data Structure (Queue)
Data Structure (Queue)
 
Queue
QueueQueue
Queue
 
Queue
QueueQueue
Queue
 
Queues-and-CQueue-Implementation
Queues-and-CQueue-ImplementationQueues-and-CQueue-Implementation
Queues-and-CQueue-Implementation
 
Team 6
Team 6Team 6
Team 6
 
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
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data Structure
 
What is Stack, Its Operations, Queue, Circular Queue, Priority Queue
What is Stack, Its Operations, Queue, Circular Queue, Priority QueueWhat is Stack, Its Operations, Queue, Circular Queue, Priority Queue
What is Stack, Its Operations, Queue, Circular Queue, Priority Queue
 

Similar to Queue

queue & its applications
queue & its applicationsqueue & its applications
queue & its applications
somendra kumar
 
Data Structures by Maneesh Boddu
Data Structures by Maneesh BodduData Structures by Maneesh Boddu
Data Structures by Maneesh Boddu
maneesh boddu
 
Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1
blessyboban92
 
Bca ii dfs u-2 linklist,stack,queue
Bca ii  dfs u-2 linklist,stack,queueBca ii  dfs u-2 linklist,stack,queue
Bca ii dfs u-2 linklist,stack,queue
Rai University
 
Bsc cs ii dfs u-2 linklist,stack,queue
Bsc cs ii  dfs u-2 linklist,stack,queueBsc cs ii  dfs u-2 linklist,stack,queue
Bsc cs ii dfs u-2 linklist,stack,queue
Rai University
 
Mca ii dfs u-3 linklist,stack,queue
Mca ii dfs u-3 linklist,stack,queueMca ii dfs u-3 linklist,stack,queue
Mca ii dfs u-3 linklist,stack,queue
Rai University
 
queuesArrays.ppt bbbbbbbbbbbbbbbbbbbbbbbbbb
queuesArrays.ppt bbbbbbbbbbbbbbbbbbbbbbbbbbqueuesArrays.ppt bbbbbbbbbbbbbbbbbbbbbbbbbb
queuesArrays.ppt bbbbbbbbbbbbbbbbbbbbbbbbbb
RAtna29
 
Queues presentation
Queues presentationQueues presentation
Queues presentation
Toseef Hasan
 
Data structure , stack , queue
Data structure , stack , queueData structure , stack , queue
Data structure , stack , queue
Rajkiran Nadar
 
LEC4-DS ALGO.pdf
LEC4-DS  ALGO.pdfLEC4-DS  ALGO.pdf
LEC4-DS ALGO.pdf
MuhammadUmerIhtisham
 
Ch03_stacks_and_queues.ppt
Ch03_stacks_and_queues.pptCh03_stacks_and_queues.ppt
Ch03_stacks_and_queues.ppt
OliverKane3
 
Queue(lecture8).pptx
Queue(lecture8).pptxQueue(lecture8).pptx
Queue(lecture8).pptx
singhprpg
 
Stack and queue
Stack and queueStack and queue
Stack and queue
CHANDAN KUMAR
 
05 queues
05 queues05 queues
05 queues
Rajan Gautam
 
TSAT Presentation1.pptx
TSAT Presentation1.pptxTSAT Presentation1.pptx
TSAT Presentation1.pptx
Rajitha Reddy Alugati
 
2 b queues
2 b queues2 b queues
2 b queues
Nguync91368
 
stack & queue
stack & queuestack & queue
stack & queue
manju rani
 

Similar to Queue (20)

queue & its applications
queue & its applicationsqueue & its applications
queue & its applications
 
queue_final.pptx
queue_final.pptxqueue_final.pptx
queue_final.pptx
 
Data Structures by Maneesh Boddu
Data Structures by Maneesh BodduData Structures by Maneesh Boddu
Data Structures by Maneesh Boddu
 
Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1
 
Bca ii dfs u-2 linklist,stack,queue
Bca ii  dfs u-2 linklist,stack,queueBca ii  dfs u-2 linklist,stack,queue
Bca ii dfs u-2 linklist,stack,queue
 
Bsc cs ii dfs u-2 linklist,stack,queue
Bsc cs ii  dfs u-2 linklist,stack,queueBsc cs ii  dfs u-2 linklist,stack,queue
Bsc cs ii dfs u-2 linklist,stack,queue
 
Mca ii dfs u-3 linklist,stack,queue
Mca ii dfs u-3 linklist,stack,queueMca ii dfs u-3 linklist,stack,queue
Mca ii dfs u-3 linklist,stack,queue
 
Queue
QueueQueue
Queue
 
queuesArrays.ppt bbbbbbbbbbbbbbbbbbbbbbbbbb
queuesArrays.ppt bbbbbbbbbbbbbbbbbbbbbbbbbbqueuesArrays.ppt bbbbbbbbbbbbbbbbbbbbbbbbbb
queuesArrays.ppt bbbbbbbbbbbbbbbbbbbbbbbbbb
 
Queues presentation
Queues presentationQueues presentation
Queues presentation
 
Data structure , stack , queue
Data structure , stack , queueData structure , stack , queue
Data structure , stack , queue
 
LEC4-DS ALGO.pdf
LEC4-DS  ALGO.pdfLEC4-DS  ALGO.pdf
LEC4-DS ALGO.pdf
 
Ch03_stacks_and_queues.ppt
Ch03_stacks_and_queues.pptCh03_stacks_and_queues.ppt
Ch03_stacks_and_queues.ppt
 
Queues.ppt
Queues.pptQueues.ppt
Queues.ppt
 
Queue(lecture8).pptx
Queue(lecture8).pptxQueue(lecture8).pptx
Queue(lecture8).pptx
 
Stack and queue
Stack and queueStack and queue
Stack and queue
 
05 queues
05 queues05 queues
05 queues
 
TSAT Presentation1.pptx
TSAT Presentation1.pptxTSAT Presentation1.pptx
TSAT Presentation1.pptx
 
2 b queues
2 b queues2 b queues
2 b queues
 
stack & queue
stack & queuestack & queue
stack & queue
 

Recently uploaded

H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
seandesed
 
Runway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptxRunway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptx
SupreethSP4
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
Robbie Edward Sayers
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
zwunae
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation & Control
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
Kamal Acharya
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
SamSarthak3
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
AJAYKUMARPUND1
 
English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
BrazilAccount1
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
JoytuBarua2
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Teleport Manpower Consultant
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
Pipe Restoration Solutions
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
R&R Consult
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
Kamal Acharya
 
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang,  ICLR 2024, MLILAB, KAIST AI.pdfJ.Yang,  ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Sreedhar Chowdam
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
gerogepatton
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
fxintegritypublishin
 

Recently uploaded (20)

H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
 
Runway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptxRunway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptx
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
 
English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
 
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang,  ICLR 2024, MLILAB, KAIST AI.pdfJ.Yang,  ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
 

Queue

  • 1.
  • 2. Introduction. Operations on Queue. Array representation of Queue. Type of Queue Circular Queue. Applications of Queue.
  • 3. A data structure is a particular way of organizing data in a computer so that it can be used efficiently. Different kind of data structure suits for the different kind of applications.
  • 4. DATA STRUCTURE PRIMITIVE DS NON-PRIMITIVE DS Integers Character Float Linear DS Non-Linear DS  Tree  Graph  Array  Linked list  Queue  Stack
  • 5.  Queue is a linear data structure.  It is used for temporary storage of data values.  A new element is added at one end called rear end.  The existing elements deleted from the other end called front end.  First-in-First-out property. 45 25 10 52 78 94 20 front rear
  • 6. 1.Insertion : Placing an item in a queue is called “insertion or enqueue”, which is done at the end of the queue called “rear”.
  • 7. 2.Deletion : Removing an item from a queue is called “deletion or dequeue” , which is done at the other end of the queue called “front”.
  • 8. 12 9 7 18 5 A[0] A[1] A[2] A[3] A[5] A[6] Queue rearfront 12 9 7 18 5 14 9 7 18 5 14 Queue after insertion of new element rearfront Queue after deletion of an element rearfront
  • 9. Algorithm:- enqueue Input:-queue[Max],FRONT,REAR,VALUE Output:-queue of elements Begin:- STEP:1- IF REAR= MAX-1 Print “Queue is OVERFLOW” Return. STEP:2- If (FRONT=-1) FRONT=FRONT+1 STEP:3- REAR = REAR+1 queue[REAR] = VALUE STEP:4- END. INITIALLY REAR = -1 FRONT =-1
  • 10. Algorithm:- de_queue Input:- queue[MAX],REAR,FRONT Output:-deleted data ITEM Begin:- Step:1-If (REAR=-1) Print “Queue is UNDERFLOW” Return. Step:2-ITEM=queue[FRONT] Step:3-If (REAR=FRONT) { REAR=FRONT=-1 } Else FRONT=FRONT+1 Step:4- print deleted data ITEM END.
  • 11. Circular Queue INTRODUCTION  Circular queue are used to remove the drawback of LINEAR queue.  Last element of the queue is connected back with first element of the queue.  It is also called as “Ring buffer”.
  • 12. STEP-1 If FRONT = (REAR+1)%MAX write OVERFLOW go to step 4 STEP-2 If (REAR=FRONT = -1) { REAR = FRONT = +1 } Else REAR = (REAR +1)%MAX STEP-3 CQ[REAR] = NUM STEP-4 EXIT
  • 13. STEP-1 If FRONT = -1 write UNDERFLOW go to step 3 STEP-2 ITEM =c_queue[FRONT] STEP-3 If (FRONT = REAR) { FRONT = REAR= -1 } Else{ FRONT = (FRONT +1)%MAX } STEP-3 EXIT
  • 14.  Real world applications  Cashier line in any store.  Waiting on hold for tech support.  people on an escalator.  Checkout at any book store.
  • 15. “TO MAKE AN END IS TO MAKE A beginning”. END OF PRESENTATION  Thank you for your kind attention.