SlideShare a Scribd company logo
1 of 36
GROUP MEMBERS
Names Roll No.
Fatima Saqib 39
Bilal Younus 10
Areesha Butt 58
Muhammad Fahim 42
Poshma Kiyani 02
Abdur Rehman 41
Presentation Topic
Queue
QUEUE
A queue is two ended data structure in which
items can be inserted from one end and taken
out from the other end. Therefore , the first
item inserted into queue is the first item to be
taken out from the queue. This property is
called First in First out [FIFO].
e.g: the picture given below:
Queue Example
● A queue of people in the bank who are trying to
submit utility bills.
● A line of vehicle on the motorway toll plaza.
● Consider a shared printer in a computer
laboratory. Student can send their print request to
the printer and each print request goto queue and
serve one by one.
● Computer input operations performing through
mouse and keyboard are also recorded into queue
and serve on the basis of FIFO.
QUEUE example
Deque stands for double-end queue
A data structure in which elements can be
added or deleted at either the front or rear.
But no changes can be made in the list
Deque is generalization of both stack and
queue.
Deque
Variations In Deque:
There are two variations of a deque.
 Input Restricted Deque
 Output Restricted Deque
An input restricted deque restricts the
insertion of elements at one end only, but
the deletion of elements can perform at
both the ends.
Input Restricted Deque
An output restricted queue, restricts the
deletion of elements at one end only, and
allows insertion to be done at both the ends
of deque
Output Restricted Deque
Possibilities
The two possibilities that must be considered
while inserting or deleting elements into the
queue are :
When an attempt is made to insert an element
into a deque which is already full, an overflow
occurs.
When an attempt is made to delete an
element from a deque which is empty,
underflow occurs
Deque
The Queue Operations
• A queue is like a line of people
waiting for a bank teller. The queue
has a front and a rear.
$ $
FrontRear
The Queue Operations
• New people must enter the queue at the rear.
• The C++ queue class calls this a push,
although it is usually called an enqueue
operation.
$ $
Front
Rear
The Queue Operations
• When an item is taken from the queue, it
always comes from the front. The C++ queue
calls this a pop, although it is usually called a
dequeue operation.
$ $
Front
Rear
Function of Queue
 REAR
 FRONT
 APPEND
 SERVE
 IsEmpty
 IsFull
Rear
Rear is the tail/bottom of the queue. The
entry at rear is the most recently arrived item
and must wait until the other entries are
present in the queue.
Insert
(Enqueue)
Remove
(Dequeu)
rearfront
FRONT
Front is the position from where items can be
taken out from queue. It is also termed as
head or top of the queue. The entry at the
front position is ready to be served
Insert
(Enqueue)
Remove
(Dequeu)
rearfront
APPEND
The operation to add an item at the rear
position of the queue is termed as append or
enqueue. We can append items at the rear
position of the queue until the queue is not
full. The rear points towards the position
where new item has been appended.
17 23 97 44 333After insertion:
17 23 97 44Initial queue:
Serve The operation to remove an item from
the front position of the queue is termed as
serve or dequeue. We can serve the items in
the queue until the queue is not empty. The
front points towards the position from where
the available item can be severed
SERVE
Queue is consider empty when there is
no item on front of the queue. IsEmpty
operation checks for this condition and
return true if the queue is empty else
return false.
IsEmpty
0 1 2 3 4 5 6 7
myQueue:
If no element can be appended at rear of
the queue then queue consider as full.
When rear of the queue reaches this limit,
then queue is full and the IsFull operation
return true else return false
IsFull
44 55 66 77 88 11 22 33
0 1 2 3 4 5 6 7
myQueue:
Array Implementation of Queue
• When enqueuing, the front index is always fixed and
the rear index moves forward in the array.
• There are several different algorithms to implement
Enqueue and Dequeue
front
rear
Enqueue(3)
3
front
rear
Enqueue(6)
3 6
front
rear
Enqueue(9)
3 6 9
Queue Implementation of Array
• When enqueuing, the front index is always fixed
and the rear index moves forward in the array.
• When dequeuing, the element at the front of the
queue is removed. Move all the elements after it
by one position.
Dequeue()
front
rear
6 9
Dequeue() Dequeue()
front
rear
9
rear = -1
front
Queue Implementation of Array
• Better way
• When an item is enqueued, make the rear
index move forward.
• When an item is dequeued, the front index
moves by one element towards the back of
the queue (thus removing the front item).
Array Implementation....
• A queue can be implemented with an array.
For example, this queue contains the integers
4 (at the front), 8 and 6 (at the rear).
[ 0 ] [1] [ 2 ] [ 3 ] [ 4 ] [ 5 ] . ..
An array of integers to
implement a queue of
integers
4 8 6
Array Implementation....
• The easiest implementation also
keeps track of the number of items in
the queue and the index of the first
element (at the front of the queue),
the last element (at the rear).
[ 0 ] [1] [ 2 ] [ 3 ] [ 4 ] [ 5 ] . . .
4 8 6
size3
first0
last2
..Array implementation of queues
• A queue is a first in, first out (FIFO) data structure
• This is accomplished by inserting at one end (the
rear) and deleting from the other (the front)
• To insert: put new element in location 4, and set
rear to 4
• To delete: take element from location 0, and set
front to 1
28
17 23 97 44
0 1 2 3 4 5 6 7
myQueue:
rear = 3front = 0
…Array implementation of queues
• Notice how the array contents “crawl” to the right as elements are
inserted and deleted
• This will be a problem after a while!
29
17 23 97 44 333After insertion:
23 97 44 333After deletion:
rear = 4front = 1
17 23 97 44Initial queue:
rear = 3front = 0
Representation of queue by program
• How to insert Value
• How to delete value
• How to print value
• Complete Program Example
To Insert Value
Algorithm:
R=F=-1
IF R >= SIZE THEN
PRINT ‘’Overflow’’
RETURN
ELSE {
R=R+1
[Insert Item]
Q[R]=‘’item’’
IF F=-1 THEN
F=0
}
END IF
Algorithm:
If ( FRONT = -1 ) then
print "Queue is empty"
Exit
Else
ITEM = Que [ FRONT ]
If ( FRONT = REAR )
REAR = -1
FRONT = -1
Else
FRONT = FRONT + 1
Stop
To Delete Value
Main body of program
Class of the program
Main body of program Output
ThanksYes, finished

More Related Content

What's hot (19)

QUEUE IN DATA STRUCTURE USING C
QUEUE IN DATA STRUCTURE USING CQUEUE IN DATA STRUCTURE USING C
QUEUE IN DATA STRUCTURE USING C
 
Queue
QueueQueue
Queue
 
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)
 
Unit 4 queue
Unit   4 queueUnit   4 queue
Unit 4 queue
 
My lectures circular queue
My lectures circular queueMy lectures circular queue
My lectures circular queue
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data Structure
 
Queue in Data Structure
Queue in Data Structure Queue in Data Structure
Queue in Data Structure
 
stack and queue array implementation in java.
stack and queue array implementation in java.stack and queue array implementation in java.
stack and queue array implementation in java.
 
Queue as data_structure
Queue as data_structureQueue as data_structure
Queue as data_structure
 
Lecture 2d queues
Lecture 2d queuesLecture 2d queues
Lecture 2d queues
 
Data Structure (Queue)
Data Structure (Queue)Data Structure (Queue)
Data Structure (Queue)
 
Stack
StackStack
Stack
 
Team 6
Team 6Team 6
Team 6
 
Queue data structure
Queue data structureQueue data structure
Queue data structure
 
2.1 STACK & QUEUE ADTS
2.1 STACK & QUEUE ADTS2.1 STACK & QUEUE ADTS
2.1 STACK & QUEUE ADTS
 
Queues
QueuesQueues
Queues
 
Queues
QueuesQueues
Queues
 
Circular queue
Circular queueCircular queue
Circular queue
 
Queue
QueueQueue
Queue
 

Viewers also liked

2nd International Conference on Inclusive Innovation and Innovative managemen...
2nd International Conference on Inclusive Innovation and Innovative managemen...2nd International Conference on Inclusive Innovation and Innovative managemen...
2nd International Conference on Inclusive Innovation and Innovative managemen...Pramila (มีล่า) Shrestha
 
Approaches to Model Transformation Reuse: from Concepts to A-posteriori typing
Approaches to Model Transformation Reuse: from Concepts to A-posteriori typingApproaches to Model Transformation Reuse: from Concepts to A-posteriori typing
Approaches to Model Transformation Reuse: from Concepts to A-posteriori typingmiso_uam
 
Hvetjandi samtalstækni
Hvetjandi samtalstækni Hvetjandi samtalstækni
Hvetjandi samtalstækni ingileif2507
 
Choosing a Persuasive Essay Topic
Choosing a Persuasive Essay TopicChoosing a Persuasive Essay Topic
Choosing a Persuasive Essay Topicmorag
 
Ус-давсны солилцооны зохицуулгад байгалийн гаралтай эрдэст бэлдмэлийн нөлөө
Ус-давсны солилцооны зохицуулгад байгалийн гаралтай эрдэст бэлдмэлийн нөлөөУс-давсны солилцооны зохицуулгад байгалийн гаралтай эрдэст бэлдмэлийн нөлөө
Ус-давсны солилцооны зохицуулгад байгалийн гаралтай эрдэст бэлдмэлийн нөлөөMedimpex
 
'What's it like to be an app?' experience prototyping workshop -- the output
'What's it like to be an app?' experience prototyping workshop -- the output'What's it like to be an app?' experience prototyping workshop -- the output
'What's it like to be an app?' experience prototyping workshop -- the outputMade by Many
 

Viewers also liked (13)

2nd International Conference on Inclusive Innovation and Innovative managemen...
2nd International Conference on Inclusive Innovation and Innovative managemen...2nd International Conference on Inclusive Innovation and Innovative managemen...
2nd International Conference on Inclusive Innovation and Innovative managemen...
 
Hombre
HombreHombre
Hombre
 
Domin ocartel
Domin ocartelDomin ocartel
Domin ocartel
 
01.03.2013, NEWSWIRE, Issue 263
01.03.2013, NEWSWIRE, Issue 26301.03.2013, NEWSWIRE, Issue 263
01.03.2013, NEWSWIRE, Issue 263
 
Approaches to Model Transformation Reuse: from Concepts to A-posteriori typing
Approaches to Model Transformation Reuse: from Concepts to A-posteriori typingApproaches to Model Transformation Reuse: from Concepts to A-posteriori typing
Approaches to Model Transformation Reuse: from Concepts to A-posteriori typing
 
13.05.2011, NEWSWIRE, Issue 167
13.05.2011, NEWSWIRE, Issue 16713.05.2011, NEWSWIRE, Issue 167
13.05.2011, NEWSWIRE, Issue 167
 
The Next Small Thing
The Next Small ThingThe Next Small Thing
The Next Small Thing
 
Hvetjandi samtalstækni
Hvetjandi samtalstækni Hvetjandi samtalstækni
Hvetjandi samtalstækni
 
Choosing a Persuasive Essay Topic
Choosing a Persuasive Essay TopicChoosing a Persuasive Essay Topic
Choosing a Persuasive Essay Topic
 
Ус-давсны солилцооны зохицуулгад байгалийн гаралтай эрдэст бэлдмэлийн нөлөө
Ус-давсны солилцооны зохицуулгад байгалийн гаралтай эрдэст бэлдмэлийн нөлөөУс-давсны солилцооны зохицуулгад байгалийн гаралтай эрдэст бэлдмэлийн нөлөө
Ус-давсны солилцооны зохицуулгад байгалийн гаралтай эрдэст бэлдмэлийн нөлөө
 
'What's it like to be an app?' experience prototyping workshop -- the output
'What's it like to be an app?' experience prototyping workshop -- the output'What's it like to be an app?' experience prototyping workshop -- the output
'What's it like to be an app?' experience prototyping workshop -- the output
 
Rubén Darío
Rubén DaríoRubén Darío
Rubén Darío
 
project OS
project  OSproject  OS
project OS
 

Similar to Queue

Stack and Queue.pptx
Stack and Queue.pptxStack and Queue.pptx
Stack and Queue.pptxDdushb
 
@Chapter 4 DSA Part II.pptx
@Chapter 4 DSA Part II.pptx@Chapter 4 DSA Part II.pptx
@Chapter 4 DSA Part II.pptxNuraMohamed9
 
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
 
Queue data structures and operation on data structures
Queue data structures and operation on data structuresQueue data structures and operation on data structures
Queue data structures and operation on data structuresmuskans14
 
Queue - Data Structure - Notes
Queue - Data Structure - NotesQueue - Data Structure - Notes
Queue - Data Structure - NotesOmprakash Chauhan
 
Data structure.ppt
Data structure.pptData structure.ppt
Data structure.pptSajalFayyaz
 
VCE Unit 03vv.pptx
VCE Unit 03vv.pptxVCE Unit 03vv.pptx
VCE Unit 03vv.pptxskilljiolms
 
Unit ii linear data structures
Unit ii linear data structures Unit ii linear data structures
Unit ii linear data structures LavanyaJ28
 
basics of queues
basics of queuesbasics of queues
basics of queuessirmanohar
 
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
 

Similar to Queue (20)

Stack and Queue.pptx
Stack and Queue.pptxStack and Queue.pptx
Stack and Queue.pptx
 
@Chapter 4 DSA Part II.pptx
@Chapter 4 DSA Part II.pptx@Chapter 4 DSA Part II.pptx
@Chapter 4 DSA Part II.pptx
 
queue.pptx
queue.pptxqueue.pptx
queue.pptx
 
Stack.pptx
Stack.pptxStack.pptx
Stack.pptx
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data Structure
 
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
 
Queues
Queues Queues
Queues
 
Queue data structures and operation on data structures
Queue data structures and operation on data structuresQueue data structures and operation on data structures
Queue data structures and operation on data structures
 
Queue - Data Structure - Notes
Queue - Data Structure - NotesQueue - Data Structure - Notes
Queue - Data Structure - Notes
 
Data structure.ppt
Data structure.pptData structure.ppt
Data structure.ppt
 
Queue and its operations
Queue and its operationsQueue and its operations
Queue and its operations
 
LEC4-DS ALGO.pdf
LEC4-DS  ALGO.pdfLEC4-DS  ALGO.pdf
LEC4-DS ALGO.pdf
 
QUEUE.pptx
QUEUE.pptxQUEUE.pptx
QUEUE.pptx
 
Lect 17-18 Zaheer Abbas
Lect 17-18 Zaheer AbbasLect 17-18 Zaheer Abbas
Lect 17-18 Zaheer Abbas
 
VCE Unit 03vv.pptx
VCE Unit 03vv.pptxVCE Unit 03vv.pptx
VCE Unit 03vv.pptx
 
Queues.ppt
Queues.pptQueues.ppt
Queues.ppt
 
Unit ii linear data structures
Unit ii linear data structures Unit ii linear data structures
Unit ii linear data structures
 
Data Structures - Lecture 6 [queues]
Data Structures - Lecture 6 [queues]Data Structures - Lecture 6 [queues]
Data Structures - Lecture 6 [queues]
 
basics of queues
basics of queuesbasics of queues
basics of queues
 
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
 

More from Abdur Rehman

Financial accounting
Financial accountingFinancial accounting
Financial accountingAbdur Rehman
 
Valid & invalid arguments
Valid & invalid argumentsValid & invalid arguments
Valid & invalid argumentsAbdur Rehman
 
Proving existential statements
Proving existential statementsProving existential statements
Proving existential statementsAbdur Rehman
 
Method of direct proof
Method of direct proofMethod of direct proof
Method of direct proofAbdur Rehman
 
Proofs by contraposition
Proofs by contrapositionProofs by contraposition
Proofs by contrapositionAbdur Rehman
 
Converse, contrapositive, inverse
Converse, contrapositive, inverseConverse, contrapositive, inverse
Converse, contrapositive, inverseAbdur Rehman
 
Constructing circuits for boolean expressions(gate)
Constructing circuits for boolean expressions(gate)Constructing circuits for boolean expressions(gate)
Constructing circuits for boolean expressions(gate)Abdur Rehman
 
Application of bases
Application of basesApplication of bases
Application of basesAbdur Rehman
 
Intro to disceret structure
Intro to disceret structureIntro to disceret structure
Intro to disceret structureAbdur Rehman
 
logic, preposition etc
logic, preposition etclogic, preposition etc
logic, preposition etcAbdur Rehman
 

More from Abdur Rehman (18)

Financial accounting
Financial accountingFinancial accounting
Financial accounting
 
Dscrete structure
Dscrete  structureDscrete  structure
Dscrete structure
 
Valid & invalid arguments
Valid & invalid argumentsValid & invalid arguments
Valid & invalid arguments
 
Sets
SetsSets
Sets
 
Sequences
SequencesSequences
Sequences
 
Recursion
RecursionRecursion
Recursion
 
Quantification
QuantificationQuantification
Quantification
 
Proving existential statements
Proving existential statementsProving existential statements
Proving existential statements
 
Method of direct proof
Method of direct proofMethod of direct proof
Method of direct proof
 
Proofs by contraposition
Proofs by contrapositionProofs by contraposition
Proofs by contraposition
 
Laws in disceret
Laws in disceretLaws in disceret
Laws in disceret
 
Converse, contrapositive, inverse
Converse, contrapositive, inverseConverse, contrapositive, inverse
Converse, contrapositive, inverse
 
Constructing circuits for boolean expressions(gate)
Constructing circuits for boolean expressions(gate)Constructing circuits for boolean expressions(gate)
Constructing circuits for boolean expressions(gate)
 
Application of bases
Application of basesApplication of bases
Application of bases
 
Truth table
Truth tableTruth table
Truth table
 
Intro to disceret structure
Intro to disceret structureIntro to disceret structure
Intro to disceret structure
 
Dst lec3
Dst lec3Dst lec3
Dst lec3
 
logic, preposition etc
logic, preposition etclogic, preposition etc
logic, preposition etc
 

Recently uploaded

The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersChitralekhaTherkar
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 

Recently uploaded (20)

The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of Powders
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 

Queue

  • 1.
  • 2.
  • 3. GROUP MEMBERS Names Roll No. Fatima Saqib 39 Bilal Younus 10 Areesha Butt 58 Muhammad Fahim 42 Poshma Kiyani 02 Abdur Rehman 41
  • 5. QUEUE A queue is two ended data structure in which items can be inserted from one end and taken out from the other end. Therefore , the first item inserted into queue is the first item to be taken out from the queue. This property is called First in First out [FIFO]. e.g: the picture given below:
  • 6. Queue Example ● A queue of people in the bank who are trying to submit utility bills. ● A line of vehicle on the motorway toll plaza. ● Consider a shared printer in a computer laboratory. Student can send their print request to the printer and each print request goto queue and serve one by one. ● Computer input operations performing through mouse and keyboard are also recorded into queue and serve on the basis of FIFO.
  • 8. Deque stands for double-end queue A data structure in which elements can be added or deleted at either the front or rear. But no changes can be made in the list Deque is generalization of both stack and queue. Deque
  • 9. Variations In Deque: There are two variations of a deque.  Input Restricted Deque  Output Restricted Deque
  • 10. An input restricted deque restricts the insertion of elements at one end only, but the deletion of elements can perform at both the ends. Input Restricted Deque
  • 11. An output restricted queue, restricts the deletion of elements at one end only, and allows insertion to be done at both the ends of deque Output Restricted Deque
  • 12. Possibilities The two possibilities that must be considered while inserting or deleting elements into the queue are : When an attempt is made to insert an element into a deque which is already full, an overflow occurs. When an attempt is made to delete an element from a deque which is empty, underflow occurs Deque
  • 13. The Queue Operations • A queue is like a line of people waiting for a bank teller. The queue has a front and a rear. $ $ FrontRear
  • 14. The Queue Operations • New people must enter the queue at the rear. • The C++ queue class calls this a push, although it is usually called an enqueue operation. $ $ Front Rear
  • 15. The Queue Operations • When an item is taken from the queue, it always comes from the front. The C++ queue calls this a pop, although it is usually called a dequeue operation. $ $ Front Rear
  • 16. Function of Queue  REAR  FRONT  APPEND  SERVE  IsEmpty  IsFull
  • 17. Rear Rear is the tail/bottom of the queue. The entry at rear is the most recently arrived item and must wait until the other entries are present in the queue. Insert (Enqueue) Remove (Dequeu) rearfront
  • 18. FRONT Front is the position from where items can be taken out from queue. It is also termed as head or top of the queue. The entry at the front position is ready to be served Insert (Enqueue) Remove (Dequeu) rearfront
  • 19. APPEND The operation to add an item at the rear position of the queue is termed as append or enqueue. We can append items at the rear position of the queue until the queue is not full. The rear points towards the position where new item has been appended. 17 23 97 44 333After insertion: 17 23 97 44Initial queue:
  • 20. Serve The operation to remove an item from the front position of the queue is termed as serve or dequeue. We can serve the items in the queue until the queue is not empty. The front points towards the position from where the available item can be severed SERVE
  • 21. Queue is consider empty when there is no item on front of the queue. IsEmpty operation checks for this condition and return true if the queue is empty else return false. IsEmpty 0 1 2 3 4 5 6 7 myQueue:
  • 22. If no element can be appended at rear of the queue then queue consider as full. When rear of the queue reaches this limit, then queue is full and the IsFull operation return true else return false IsFull 44 55 66 77 88 11 22 33 0 1 2 3 4 5 6 7 myQueue:
  • 23. Array Implementation of Queue • When enqueuing, the front index is always fixed and the rear index moves forward in the array. • There are several different algorithms to implement Enqueue and Dequeue front rear Enqueue(3) 3 front rear Enqueue(6) 3 6 front rear Enqueue(9) 3 6 9
  • 24. Queue Implementation of Array • When enqueuing, the front index is always fixed and the rear index moves forward in the array. • When dequeuing, the element at the front of the queue is removed. Move all the elements after it by one position. Dequeue() front rear 6 9 Dequeue() Dequeue() front rear 9 rear = -1 front
  • 25. Queue Implementation of Array • Better way • When an item is enqueued, make the rear index move forward. • When an item is dequeued, the front index moves by one element towards the back of the queue (thus removing the front item).
  • 26. Array Implementation.... • A queue can be implemented with an array. For example, this queue contains the integers 4 (at the front), 8 and 6 (at the rear). [ 0 ] [1] [ 2 ] [ 3 ] [ 4 ] [ 5 ] . .. An array of integers to implement a queue of integers 4 8 6
  • 27. Array Implementation.... • The easiest implementation also keeps track of the number of items in the queue and the index of the first element (at the front of the queue), the last element (at the rear). [ 0 ] [1] [ 2 ] [ 3 ] [ 4 ] [ 5 ] . . . 4 8 6 size3 first0 last2
  • 28. ..Array implementation of queues • A queue is a first in, first out (FIFO) data structure • This is accomplished by inserting at one end (the rear) and deleting from the other (the front) • To insert: put new element in location 4, and set rear to 4 • To delete: take element from location 0, and set front to 1 28 17 23 97 44 0 1 2 3 4 5 6 7 myQueue: rear = 3front = 0
  • 29. …Array implementation of queues • Notice how the array contents “crawl” to the right as elements are inserted and deleted • This will be a problem after a while! 29 17 23 97 44 333After insertion: 23 97 44 333After deletion: rear = 4front = 1 17 23 97 44Initial queue: rear = 3front = 0
  • 30. Representation of queue by program • How to insert Value • How to delete value • How to print value • Complete Program Example
  • 31. To Insert Value Algorithm: R=F=-1 IF R >= SIZE THEN PRINT ‘’Overflow’’ RETURN ELSE { R=R+1 [Insert Item] Q[R]=‘’item’’ IF F=-1 THEN F=0 } END IF
  • 32. Algorithm: If ( FRONT = -1 ) then print "Queue is empty" Exit Else ITEM = Que [ FRONT ] If ( FRONT = REAR ) REAR = -1 FRONT = -1 Else FRONT = FRONT + 1 Stop To Delete Value
  • 33. Main body of program
  • 34. Class of the program
  • 35. Main body of program Output