SlideShare a Scribd company logo
1 of 27
Queues
DATA STRUCTURES
• A data structures is a logical model of a
particular organization of data.
• It is basically a group of data elements that
are put together under one name and which
defines a particular way of storing and
organizing data in a computer so that it can be
used efficiently.
Classifications of data structures
• Primitive: This is the type of data structures
which are supported by programming
language. Example-int, real, character,
boolean.
• Non primitive: This is the type of data
structures in which are created using primitive
data structures. Example-linked lists, stacks,
trees, graphs.
classification
Defination of queue
• A queue is an important data structure which
is extensively used in computer application.
• A queue is a data structure that models the
first-come first-serve order.
• That is, the element that is inserted first into
the queue will be the element that will
deleted first, and the element that is inserted
last is deleted last.
• A waiting line is a good real-life example of a
queue.
• The element in the queue are added at one
end called “rear” and removed from another
end called front.
• The process of inserting element in the queue
is called enqueue and the process of deleting
element from the queue is dequeue.
front=0 1 rear= 2 3
2 4 6
Implementation of queues
Queues can be implemented either as an array
or an linked list.
•Array representation of queue:
0 1 3 4 5 6 7 8
12
Front
=0
9 8 2 6
Rear=
5
Operations performed on the queue
1. Insertion:
0 1 2 3 4 5 6 7
After insertion:
• Front=0
• Rear=5
12 9 8 2 6 10
Algorithm for insertion
step.1: if rear=max-1,then write “overflow”
and exit.
[ end of if loop]
Step.2: if front=-1 and rear=-1 then,
set front=0 and rear=0
Else
rear=rear+1.
[end of if loop]
Step.3:set queue[rear]=num.
Step.4:exit.
Deletion operation
• Queue after deletion:
0 1 2 3 4 5 6 7
• Front=1
• Rear=5
9 8 2 6 10
Algorithm for deletion
Step:1. If front=-1 or front>rear then,
Write “underflow”.
else
Set val=queue[front].
Set front=front+1.
[end of if]
Step.2 exit.
Linked representation of queue
• In linked queue, every element has 2 parts
one that stores the data and other that stores
the address of next element.
• The start pointer is used as first and another
pointer called rear for the last element in the
queue.
• If front=rear=null, then it indicated that queue
is empty.
Operations on linked queue
1. Insertion
2. Deletion
Linked queue is:
front rear
3 4 8 null
• Linked queue after insertion:
Front rear
• Linked queue after deletion:
Front rear
3 4 8 12 null
4 8 null
Types of queue
• Circular queue
• Dequeue
• Priority queue
• Multiple queue
Circular queue
In a standard queue data structure re-buffering
problem occurs for each dequeue operation. To
solve this problem by joining the front and rear
ends of a queue to make the queue as circular
queue.
•Circular queue is a linear data structure. It follows
FIFO principle.
•In circular queue the last node is connected back
to the first node to make a circle.
•it is also called as “ring buffers”.
• Elements are added at the rear end and
deleted at the front end of the queue.
• Both the front and rear pointers points to the
beginning of the array.
Circular queue can be created in three ways:
1.Using singly linked list
2.Using doubly linked list
3.Using arrays
Circular queue using arrays
2 3 4
dequeue
• A dequeue is a data structure in which
elements can be inserted or deleted from
both the side(rear or front).
• However no elements can be added or
deleted from middle.
• In a computer memory, dequeue is
implemented using either a circular array or
circular doubly linked list.
• 2 pointers are maintained left and right.
• Since it is circular, dequeue[n-1] is followed by
dequeue[0].
There are two varients of double ended queue
1.Input restricted: In this dequeue insertions
can be done only at one of the end while
deletions can be done from both ends.
2.Output restricted: Deletion can be done only
at one end while insertions can done on both
the ends.
• The dequeue is represented as follows:
• front rear
insertion deletion
0 1 2 3
Priority queue
• A priority queue is a data structure in which
each element is assigned a priority.
• The priority of each element will be used to
determine the order in which element will be
processed.
General rules of procesing:
• an element with higher priority is processed
before an element with lower priority.
• Two elements with same priority is processed
on first come first serve basis.
• The priority of the process may be set based
on the CPU time it requires to get executed
easily.
Application:
1.Priority queue are widely used in operationg
system to execute the highest priority process
first.
Implementation of priority queue
• Linked representation of priority queue:
Priority=1 priority=2 priority=3
Lower priority means higher number.
Lower priority number means higher priority.
a 1 b 2 c 3 *
Multiple queue
• When we implement a queue using array, size
of array must be known in advance.
• If the queue is allocated less space, then
overflow conditions will encountered. So
modification will have to be done to reallocate
more space for the array.
• So a better solution to deal with this problem
to have multiple queues or to have more than
one queue in the same array of sufficient size.
• In the given figure an array queue[n] is used
to represent two queues ,queue A and queue
B.
• The value of n is such that the combined size
of both the queues will never exceed n.
queue A queue B
0 1 2 3 n-3 n-2 n-1
Multiple queue
Applications of Queues
• Direct applications
–Waiting lists, bureaucracy
–Access to shared resources (e.g., printer)
–Multiprogramming
–Queues are used in operating system for
handling interrupts.
–queues are used in playlist for jukebox to
add songs to the end, play from the front of
the list.

More Related Content

What's hot (20)

queue & its applications
queue & its applicationsqueue & its applications
queue & its applications
 
Sorting
SortingSorting
Sorting
 
Threaded Binary Tree.pptx
Threaded Binary Tree.pptxThreaded Binary Tree.pptx
Threaded Binary Tree.pptx
 
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
 
My lectures circular queue
My lectures circular queueMy lectures circular queue
My lectures circular queue
 
stack & queue
stack & queuestack & queue
stack & queue
 
SEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMSSEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMS
 
Circular queue
Circular queueCircular queue
Circular queue
 
Bubble sort
Bubble sortBubble sort
Bubble sort
 
Quick Sort , Merge Sort , Heap Sort
Quick Sort , Merge Sort ,  Heap SortQuick Sort , Merge Sort ,  Heap Sort
Quick Sort , Merge Sort , Heap Sort
 
Queue ppt
Queue pptQueue ppt
Queue ppt
 
Queues
QueuesQueues
Queues
 
Data Structure (Queue)
Data Structure (Queue)Data Structure (Queue)
Data Structure (Queue)
 
Quick Sort
Quick SortQuick Sort
Quick Sort
 
stack presentation
stack presentationstack presentation
stack presentation
 
linear search and binary search
linear search and binary searchlinear search and binary search
linear search and binary search
 
Linked List
Linked ListLinked List
Linked List
 
Ppt bubble sort
Ppt bubble sortPpt bubble sort
Ppt bubble sort
 
Red black tree
Red black treeRed black tree
Red black tree
 
Linked list in Data Structure and Algorithm
Linked list in Data Structure and Algorithm Linked list in Data Structure and Algorithm
Linked list in Data Structure and Algorithm
 

Similar to Queues

Unit ii linear data structures
Unit ii linear data structures Unit ii linear data structures
Unit ii linear data structures LavanyaJ28
 
Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1blessyboban92
 
10994103.ppt
10994103.ppt10994103.ppt
10994103.pptSushmaG48
 
Queue ADT for data structure for computer
Queue ADT for data structure for computerQueue ADT for data structure for computer
Queue ADT for data structure for computerabinathsabi
 
stacks and queues for public
stacks and queues for publicstacks and queues for public
stacks and queues for publiciqbalphy1
 
Lesson 4 - Queue ADT.pdf
Lesson 4 - Queue ADT.pdfLesson 4 - Queue ADT.pdf
Lesson 4 - Queue ADT.pdfLeandroJrErcia
 
Stack and Queue.pptx
Stack and Queue.pptxStack and Queue.pptx
Stack and Queue.pptxDdushb
 
DS Module1 (1).pptx
DS Module1 (1).pptxDS Module1 (1).pptx
DS Module1 (1).pptxAnuJoseph95
 
1.Introduction to Data Structures and Algorithms.pptx
1.Introduction to Data Structures and Algorithms.pptx1.Introduction to Data Structures and Algorithms.pptx
1.Introduction to Data Structures and Algorithms.pptxBlueSwede
 
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)Self-Employed
 
Introduction data structure
Introduction data structureIntroduction data structure
Introduction data structureMuhammad Ismail
 
Data Structures in C
Data Structures in CData Structures in C
Data Structures in CJabs6
 
08_Queues.pptx showing how que works given vertex
08_Queues.pptx showing how que works given vertex08_Queues.pptx showing how que works given vertex
08_Queues.pptx showing how que works given vertexSadiaSharmin40
 
Implementation of queue using singly and doubly linked list.
Implementation of queue using singly and doubly linked list.Implementation of queue using singly and doubly linked list.
Implementation of queue using singly and doubly linked list.central university of bihar
 

Similar to Queues (20)

Queues
Queues Queues
Queues
 
Unit ii linear data structures
Unit ii linear data structures Unit ii linear data structures
Unit ii linear data structures
 
Data Structures 2
Data Structures 2Data Structures 2
Data Structures 2
 
Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1
 
queue.pptx
queue.pptxqueue.pptx
queue.pptx
 
10994103.ppt
10994103.ppt10994103.ppt
10994103.ppt
 
Queue ADT for data structure for computer
Queue ADT for data structure for computerQueue ADT for data structure for computer
Queue ADT for data structure for computer
 
Data Structures 6
Data Structures 6Data Structures 6
Data Structures 6
 
stacks and queues for public
stacks and queues for publicstacks and queues for public
stacks and queues for public
 
Lesson 4 - Queue ADT.pdf
Lesson 4 - Queue ADT.pdfLesson 4 - Queue ADT.pdf
Lesson 4 - Queue ADT.pdf
 
Stack and Queue.pptx
Stack and Queue.pptxStack and Queue.pptx
Stack and Queue.pptx
 
DS Module1 (1).pptx
DS Module1 (1).pptxDS Module1 (1).pptx
DS Module1 (1).pptx
 
1.Introduction to Data Structures and Algorithms.pptx
1.Introduction to Data Structures and Algorithms.pptx1.Introduction to Data Structures and Algorithms.pptx
1.Introduction to Data Structures and Algorithms.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)
 
Introduction data structure
Introduction data structureIntroduction data structure
Introduction data structure
 
Data Structures in C
Data Structures in CData Structures in C
Data Structures in C
 
Queue
QueueQueue
Queue
 
stack.pptx
stack.pptxstack.pptx
stack.pptx
 
08_Queues.pptx showing how que works given vertex
08_Queues.pptx showing how que works given vertex08_Queues.pptx showing how que works given vertex
08_Queues.pptx showing how que works given vertex
 
Implementation of queue using singly and doubly linked list.
Implementation of queue using singly and doubly linked list.Implementation of queue using singly and doubly linked list.
Implementation of queue using singly and doubly linked list.
 

More from Lovely Professional University

The HyperText Markup Language or HTML is the standard markup language
The HyperText Markup Language or HTML is the standard markup languageThe HyperText Markup Language or HTML is the standard markup language
The HyperText Markup Language or HTML is the standard markup languageLovely Professional University
 

More from Lovely Professional University (20)

The HyperText Markup Language or HTML is the standard markup language
The HyperText Markup Language or HTML is the standard markup languageThe HyperText Markup Language or HTML is the standard markup language
The HyperText Markup Language or HTML is the standard markup language
 
Working with JSON
Working with JSONWorking with JSON
Working with JSON
 
Yargs Module
Yargs ModuleYargs Module
Yargs Module
 
NODEMON Module
NODEMON ModuleNODEMON Module
NODEMON Module
 
Getting Input from User
Getting Input from UserGetting Input from User
Getting Input from User
 
fs Module.pptx
fs Module.pptxfs Module.pptx
fs Module.pptx
 
Transaction Processing in DBMS.pptx
Transaction Processing in DBMS.pptxTransaction Processing in DBMS.pptx
Transaction Processing in DBMS.pptx
 
web_server_browser.ppt
web_server_browser.pptweb_server_browser.ppt
web_server_browser.ppt
 
Web Server.pptx
Web Server.pptxWeb Server.pptx
Web Server.pptx
 
Number System.pptx
Number System.pptxNumber System.pptx
Number System.pptx
 
Programming Language.ppt
Programming Language.pptProgramming Language.ppt
Programming Language.ppt
 
Information System.pptx
Information System.pptxInformation System.pptx
Information System.pptx
 
Applications of Computer Science in Pharmacy-1.pptx
Applications of Computer Science in Pharmacy-1.pptxApplications of Computer Science in Pharmacy-1.pptx
Applications of Computer Science in Pharmacy-1.pptx
 
Application of Computers in Pharmacy.pptx
Application of Computers in Pharmacy.pptxApplication of Computers in Pharmacy.pptx
Application of Computers in Pharmacy.pptx
 
Deploying your app.pptx
Deploying your app.pptxDeploying your app.pptx
Deploying your app.pptx
 
Setting up github and ssh keys.ppt
Setting up github and ssh keys.pptSetting up github and ssh keys.ppt
Setting up github and ssh keys.ppt
 
Adding a New Feature and Deploying.ppt
Adding a New Feature and Deploying.pptAdding a New Feature and Deploying.ppt
Adding a New Feature and Deploying.ppt
 
Requiring your own files.pptx
Requiring your own files.pptxRequiring your own files.pptx
Requiring your own files.pptx
 
Unit-2 Getting Input from User.pptx
Unit-2 Getting Input from User.pptxUnit-2 Getting Input from User.pptx
Unit-2 Getting Input from User.pptx
 
Yargs Module.pptx
Yargs Module.pptxYargs Module.pptx
Yargs Module.pptx
 

Recently uploaded

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
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacingjaychoudhary37
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
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
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 

Recently uploaded (20)

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
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacing
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
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
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 

Queues

  • 2. DATA STRUCTURES • A data structures is a logical model of a particular organization of data. • It is basically a group of data elements that are put together under one name and which defines a particular way of storing and organizing data in a computer so that it can be used efficiently.
  • 3. Classifications of data structures • Primitive: This is the type of data structures which are supported by programming language. Example-int, real, character, boolean. • Non primitive: This is the type of data structures in which are created using primitive data structures. Example-linked lists, stacks, trees, graphs.
  • 5. Defination of queue • A queue is an important data structure which is extensively used in computer application. • A queue is a data structure that models the first-come first-serve order. • That is, the element that is inserted first into the queue will be the element that will deleted first, and the element that is inserted last is deleted last. • A waiting line is a good real-life example of a queue.
  • 6. • The element in the queue are added at one end called “rear” and removed from another end called front. • The process of inserting element in the queue is called enqueue and the process of deleting element from the queue is dequeue. front=0 1 rear= 2 3 2 4 6
  • 7. Implementation of queues Queues can be implemented either as an array or an linked list. •Array representation of queue: 0 1 3 4 5 6 7 8 12 Front =0 9 8 2 6 Rear= 5
  • 8. Operations performed on the queue 1. Insertion: 0 1 2 3 4 5 6 7 After insertion: • Front=0 • Rear=5 12 9 8 2 6 10
  • 9. Algorithm for insertion step.1: if rear=max-1,then write “overflow” and exit. [ end of if loop] Step.2: if front=-1 and rear=-1 then, set front=0 and rear=0 Else rear=rear+1. [end of if loop] Step.3:set queue[rear]=num. Step.4:exit.
  • 10. Deletion operation • Queue after deletion: 0 1 2 3 4 5 6 7 • Front=1 • Rear=5 9 8 2 6 10
  • 11. Algorithm for deletion Step:1. If front=-1 or front>rear then, Write “underflow”. else Set val=queue[front]. Set front=front+1. [end of if] Step.2 exit.
  • 12. Linked representation of queue • In linked queue, every element has 2 parts one that stores the data and other that stores the address of next element. • The start pointer is used as first and another pointer called rear for the last element in the queue. • If front=rear=null, then it indicated that queue is empty.
  • 13. Operations on linked queue 1. Insertion 2. Deletion Linked queue is: front rear 3 4 8 null
  • 14. • Linked queue after insertion: Front rear • Linked queue after deletion: Front rear 3 4 8 12 null 4 8 null
  • 15. Types of queue • Circular queue • Dequeue • Priority queue • Multiple queue
  • 16. Circular queue In a standard queue data structure re-buffering problem occurs for each dequeue operation. To solve this problem by joining the front and rear ends of a queue to make the queue as circular queue. •Circular queue is a linear data structure. It follows FIFO principle. •In circular queue the last node is connected back to the first node to make a circle. •it is also called as “ring buffers”.
  • 17. • Elements are added at the rear end and deleted at the front end of the queue. • Both the front and rear pointers points to the beginning of the array. Circular queue can be created in three ways: 1.Using singly linked list 2.Using doubly linked list 3.Using arrays
  • 18. Circular queue using arrays 2 3 4
  • 19. dequeue • A dequeue is a data structure in which elements can be inserted or deleted from both the side(rear or front). • However no elements can be added or deleted from middle. • In a computer memory, dequeue is implemented using either a circular array or circular doubly linked list. • 2 pointers are maintained left and right.
  • 20. • Since it is circular, dequeue[n-1] is followed by dequeue[0]. There are two varients of double ended queue 1.Input restricted: In this dequeue insertions can be done only at one of the end while deletions can be done from both ends. 2.Output restricted: Deletion can be done only at one end while insertions can done on both the ends.
  • 21. • The dequeue is represented as follows: • front rear insertion deletion 0 1 2 3
  • 22. Priority queue • A priority queue is a data structure in which each element is assigned a priority. • The priority of each element will be used to determine the order in which element will be processed. General rules of procesing: • an element with higher priority is processed before an element with lower priority.
  • 23. • Two elements with same priority is processed on first come first serve basis. • The priority of the process may be set based on the CPU time it requires to get executed easily. Application: 1.Priority queue are widely used in operationg system to execute the highest priority process first.
  • 24. Implementation of priority queue • Linked representation of priority queue: Priority=1 priority=2 priority=3 Lower priority means higher number. Lower priority number means higher priority. a 1 b 2 c 3 *
  • 25. Multiple queue • When we implement a queue using array, size of array must be known in advance. • If the queue is allocated less space, then overflow conditions will encountered. So modification will have to be done to reallocate more space for the array. • So a better solution to deal with this problem to have multiple queues or to have more than one queue in the same array of sufficient size.
  • 26. • In the given figure an array queue[n] is used to represent two queues ,queue A and queue B. • The value of n is such that the combined size of both the queues will never exceed n. queue A queue B 0 1 2 3 n-3 n-2 n-1 Multiple queue
  • 27. Applications of Queues • Direct applications –Waiting lists, bureaucracy –Access to shared resources (e.g., printer) –Multiprogramming –Queues are used in operating system for handling interrupts. –queues are used in playlist for jukebox to add songs to the end, play from the front of the list.