SlideShare une entreprise Scribd logo
1  sur  24
Contents
Introduction
Operations on queue
Array representation of queues
Linked representation of queues
Types of queues
Circular queues
Deques
Priority queues
Application of queues
References
DATA STRUCTURE
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
Linear
Array
Linked list
Stack
Queue
Primitive DS Non-Primitive DS
Non Linear
Tree
Graph
Integer
Float
Char
Pointers
• 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.
34 12 53 61 9 23 42
front
rear
Operations on Queue
1.Insertion :
Placing an item in a queue is called “insertion or
enqueue”, which is done at the end of the queue
called “rear”.
Front
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”.
Front
Rear
Array Representation of Queues
12 9 7 18
12 9 7 18 14
A[0] A[1] A[2] A[3] A[4]
QUEUE
front
rear
front
rearQueue after insertion of a new element
9 7 18 14
front rear
Queue after deletion of an element
Algorithm to insert an element in queue
STEP-1 IF REAR= MAX-1
write OVERFLOW
go to step 4
[end of if]
STEP-2 if REAR = -1
set FRONT=REAR= 0
else
set REAR = REAR+1
STEP-3 set QUEUE [ REAR ] = NUM
STEP-4 EXIT
INITIALLY
REAR = -1
FRONT =-1
Algorithm to delete an element from queue
STEP-1 If FRONT = -1 or FRONT > REAR
write UNDERFLOW
Else
set VAL = QUEUE [ FRONT ]
set FRONT = FRONT + 1
[end of if]
STEP-2 EXIT
Linked Representation of Queues
9 300 7 350 4 360 2 N
290 Front 300 350 360 rear
Linked queue
9 300 7 350 4 360 2 380
290 front 300 350 360 380 rear
5 N
Linked queue after inserting a node
7 350 4 360 2 380
380 rear
5 N
300 front 350 360
Linked queue after deleting a node
Front = 290
Rear = 360
Algorithm to insert an element in queue
using linked list
STEP-1 Allocate memory for the new node & name it as TEMP.
STEP-2 set TEMP data = NUM
set TEMP link = NULL
STEP-3 If FRONT = NULL
FRONT = REAR = TEMP
Else
REAR link = TEMP
REAR = TEMP
[ end of if]
STEP-4 EXIT
INITIALLY
FRONT=NULL
REAR=NULL
Algorithm to delete an element from queue
STEP-1 If FRONT = NULL
write underflow
go to step 3.
[end of if]
STEP-2 set TEMP = FRONT
FRONT = FRONT link
if FRONT = NULL
REAR = NULL
STEP-3 EXIT
Types of Queues
1. Deque
2. Circular Queue
3. Priority Queue
DEQUES
1.Deque stands for double ended queue.
2.Elements can be inserted or deleted at
either end.
3. Also known as head-tail linked list.
34 12 53 61 9
insertion
deletion deletion
insertion
front rear
Types Of Deque
1.Input restricted deque:
34 12 53 61 9
deletion deletion
insertion
front rear
2. Output restricted deque:
34 12 53 61 9
insertion
deletion
insertion
front rear
CIRCULAR QUEUES
• Circular queue are used to remove the
drawback of simple queue.
• Both the front and the rear pointers wrap
around to the beginning of the array.
•It is also called as “Ring buffer”.
Algorithm to insert an element in queue
STEP-1 If FRONT = (REAR+1)%MAX
write OVERFLOW
go to step 4
[end of if]
STEP-2 If FRONT = -1
REAR = FRONT = 0
Else REAR = (REAR +1)%MAX
[ end of if ]
STEP-3 CQ[REAR] = NUM
STEP-4 EXIT
INITIALLY
FRONT= -1
REAR= 0
Algorithm to delete an element from queue
STEP-1 If FRONT = -1
write UNDERFLOW
go to step 3
[ end of if ]
STEP-2 If FRONT = REAR
FRONT = REAR= -1
Else
FRONT = (FRONT +1)%MAX
STEP-3 EXIT
PRIORITY QUEUE
1.It is collection of elements where elements are
stored according to the their priority levels.
2.Inserting and removing of elements from queue
is decided by the priority of the elements.
3. An element of the higher priority is processed
first.
4.Two element of same priority are processed on
first-come-first-served basis.
Example: Suppose you have a few assignment from
different subjects. Which assignment will you want
to do first?
subjects Due date priority
DSGT 15 OCT 4
DLD 6 OCT 2
CYB 4 OCT 1
DS 8 OCT 3
APPLICATIONS
 Real world applications
Cashier line in any store.
Waiting on hold for tech support.
people on an escalator.
Checkout at any book store.
Applications related to computer science:
1.When data is transferred asynchronously between
two processes. eg. IO Buffers.
2.When a resource is shared among multiple
consumers. Examples include CPU scheduling,
Disk Scheduling.
3.In recognizing palindrome.
4.In shared resources management.
5.Keyboard buffer.
6.Round robin scheduling.
7.Job scheduling.
8.Simulation
queue & its applications

Contenu connexe

Tendances (20)

Tree - Data Structure
Tree - Data StructureTree - Data Structure
Tree - Data Structure
 
STACKS IN DATASTRUCTURE
STACKS IN DATASTRUCTURESTACKS IN DATASTRUCTURE
STACKS IN DATASTRUCTURE
 
Arrays
ArraysArrays
Arrays
 
Array data structure
Array data structureArray data structure
Array data structure
 
SEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMSSEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMS
 
Applications of stack
Applications of stackApplications of stack
Applications of stack
 
Queues
QueuesQueues
Queues
 
Priority Queue in Data Structure
Priority Queue in Data StructurePriority Queue in Data Structure
Priority Queue in Data Structure
 
1.1 binary tree
1.1 binary tree1.1 binary tree
1.1 binary tree
 
Doubly Linked List
Doubly Linked ListDoubly Linked List
Doubly Linked List
 
Deque and its applications
Deque and its applicationsDeque and its applications
Deque and its applications
 
Stack
StackStack
Stack
 
Stacks and Queue - Data Structures
Stacks and Queue - Data StructuresStacks and Queue - Data Structures
Stacks and Queue - Data Structures
 
Queues
QueuesQueues
Queues
 
Data Structure and Algorithms Linked List
Data Structure and Algorithms Linked ListData Structure and Algorithms Linked List
Data Structure and Algorithms Linked List
 
Selection sorting
Selection sortingSelection sorting
Selection sorting
 
Stacks IN DATA STRUCTURES
Stacks IN DATA STRUCTURESStacks IN DATA STRUCTURES
Stacks IN DATA STRUCTURES
 
Introduction to data structure ppt
Introduction to data structure pptIntroduction to data structure ppt
Introduction to data structure ppt
 
Infix to postfix conversion
Infix to postfix conversionInfix to postfix conversion
Infix to postfix conversion
 
sparse matrix in data structure
sparse matrix in data structuresparse matrix in data structure
sparse matrix in data structure
 

Similaire à queue & its applications

Similaire à queue & its applications (20)

queue_final.pptx
queue_final.pptxqueue_final.pptx
queue_final.pptx
 
Queue
QueueQueue
Queue
 
LEC4-DS ALGO.pdf
LEC4-DS  ALGO.pdfLEC4-DS  ALGO.pdf
LEC4-DS ALGO.pdf
 
Queue
QueueQueue
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
 
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
 
4. Queues in Data Structure
4. Queues in Data Structure4. Queues in Data Structure
4. Queues in Data Structure
 
Queue
QueueQueue
Queue
 
Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1
 
Stack.pptx
Stack.pptxStack.pptx
Stack.pptx
 
Data Structures by Maneesh Boddu
Data Structures by Maneesh BodduData Structures by Maneesh Boddu
Data Structures by Maneesh Boddu
 
Queue
QueueQueue
Queue
 
10994103.ppt
10994103.ppt10994103.ppt
10994103.ppt
 
05 queues
05 queues05 queues
05 queues
 
Queue - Data Structure - Notes
Queue - Data Structure - NotesQueue - Data Structure - Notes
Queue - Data Structure - Notes
 
Data structures
Data structuresData structures
Data structures
 
Queue
QueueQueue
Queue
 
cp264_lecture18_queue.ppt
cp264_lecture18_queue.pptcp264_lecture18_queue.ppt
cp264_lecture18_queue.ppt
 
Stack and queue
Stack and queueStack and queue
Stack and queue
 

Dernier

BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxfenichawla
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college projectTonystark477637
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)simmis5
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdfankushspencer015
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Christo Ananth
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdfKamal Acharya
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsRussian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 

Dernier (20)

BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsRussian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
 

queue & its applications

  • 1.
  • 2. Contents Introduction Operations on queue Array representation of queues Linked representation of queues Types of queues Circular queues Deques Priority queues Application of queues References
  • 3. DATA STRUCTURE 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 Linear Array Linked list Stack Queue Primitive DS Non-Primitive DS Non Linear Tree Graph Integer Float Char Pointers
  • 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. 34 12 53 61 9 23 42 front rear
  • 6. Operations on Queue 1.Insertion : Placing an item in a queue is called “insertion or enqueue”, which is done at the end of the queue called “rear”. Front 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”. Front Rear
  • 8. Array Representation of Queues 12 9 7 18 12 9 7 18 14 A[0] A[1] A[2] A[3] A[4] QUEUE front rear front rearQueue after insertion of a new element 9 7 18 14 front rear Queue after deletion of an element
  • 9. Algorithm to insert an element in queue STEP-1 IF REAR= MAX-1 write OVERFLOW go to step 4 [end of if] STEP-2 if REAR = -1 set FRONT=REAR= 0 else set REAR = REAR+1 STEP-3 set QUEUE [ REAR ] = NUM STEP-4 EXIT INITIALLY REAR = -1 FRONT =-1
  • 10. Algorithm to delete an element from queue STEP-1 If FRONT = -1 or FRONT > REAR write UNDERFLOW Else set VAL = QUEUE [ FRONT ] set FRONT = FRONT + 1 [end of if] STEP-2 EXIT
  • 11. Linked Representation of Queues 9 300 7 350 4 360 2 N 290 Front 300 350 360 rear Linked queue 9 300 7 350 4 360 2 380 290 front 300 350 360 380 rear 5 N Linked queue after inserting a node 7 350 4 360 2 380 380 rear 5 N 300 front 350 360 Linked queue after deleting a node Front = 290 Rear = 360
  • 12. Algorithm to insert an element in queue using linked list STEP-1 Allocate memory for the new node & name it as TEMP. STEP-2 set TEMP data = NUM set TEMP link = NULL STEP-3 If FRONT = NULL FRONT = REAR = TEMP Else REAR link = TEMP REAR = TEMP [ end of if] STEP-4 EXIT INITIALLY FRONT=NULL REAR=NULL
  • 13. Algorithm to delete an element from queue STEP-1 If FRONT = NULL write underflow go to step 3. [end of if] STEP-2 set TEMP = FRONT FRONT = FRONT link if FRONT = NULL REAR = NULL STEP-3 EXIT
  • 14. Types of Queues 1. Deque 2. Circular Queue 3. Priority Queue
  • 15. DEQUES 1.Deque stands for double ended queue. 2.Elements can be inserted or deleted at either end. 3. Also known as head-tail linked list. 34 12 53 61 9 insertion deletion deletion insertion front rear
  • 16. Types Of Deque 1.Input restricted deque: 34 12 53 61 9 deletion deletion insertion front rear 2. Output restricted deque: 34 12 53 61 9 insertion deletion insertion front rear
  • 17. CIRCULAR QUEUES • Circular queue are used to remove the drawback of simple queue. • Both the front and the rear pointers wrap around to the beginning of the array. •It is also called as “Ring buffer”.
  • 18. Algorithm to insert an element in queue STEP-1 If FRONT = (REAR+1)%MAX write OVERFLOW go to step 4 [end of if] STEP-2 If FRONT = -1 REAR = FRONT = 0 Else REAR = (REAR +1)%MAX [ end of if ] STEP-3 CQ[REAR] = NUM STEP-4 EXIT INITIALLY FRONT= -1 REAR= 0
  • 19. Algorithm to delete an element from queue STEP-1 If FRONT = -1 write UNDERFLOW go to step 3 [ end of if ] STEP-2 If FRONT = REAR FRONT = REAR= -1 Else FRONT = (FRONT +1)%MAX STEP-3 EXIT
  • 20. PRIORITY QUEUE 1.It is collection of elements where elements are stored according to the their priority levels. 2.Inserting and removing of elements from queue is decided by the priority of the elements. 3. An element of the higher priority is processed first. 4.Two element of same priority are processed on first-come-first-served basis.
  • 21. Example: Suppose you have a few assignment from different subjects. Which assignment will you want to do first? subjects Due date priority DSGT 15 OCT 4 DLD 6 OCT 2 CYB 4 OCT 1 DS 8 OCT 3
  • 22. APPLICATIONS  Real world applications Cashier line in any store. Waiting on hold for tech support. people on an escalator. Checkout at any book store.
  • 23. Applications related to computer science: 1.When data is transferred asynchronously between two processes. eg. IO Buffers. 2.When a resource is shared among multiple consumers. Examples include CPU scheduling, Disk Scheduling. 3.In recognizing palindrome. 4.In shared resources management. 5.Keyboard buffer. 6.Round robin scheduling. 7.Job scheduling. 8.Simulation