SlideShare una empresa de Scribd logo
1 de 13
RECAP
 Data structure is a particular way of storing
and organizing data in a computer so that it
can be used efficiently.
 Different kinds of data structures are suited
to different kinds of applications, and some
are highly specialized to specific tasks.
 Linear (Array, queue, Linked list and stack)
 Non Linear ( tree and graph)
INTRODUCTION TO QUEUE
In ordinary English, a queue is
defined as a waiting line, like a line
of people waiting to purchase
tickets, where the first person in
line is the first person served.
REAL LIFE EXAMPLES OF QUEUE ARE:
1. A queue of people at ticket-window: The person who
comes first gets the ticket first. The person who is
coming last is getting the tickets in last. Therefore, it
follows first-in-first-out (FIFO) strategy of queue.
2. Luggage checking machine: Luggage checking
machine checks the luggage first that comes first.
Therefore, it follows FIFO principle of queue.
3. Patients waiting outside the doctor's clinic: The
patient who comes first visits the doctor first, and the
patient who comes last visits the doctor last.
Therefore, it follows the first-in-first-out (FIFO) strategy
of queue.
IN COMPUTER APLICATION
 For computer applications, we similarly
define a queue to be a list in which all
additions to the list are made at one
end, and all deletions from the list are
made at the other end.
 Queues are also called first-in, first-out
lists , or FIFO for short.
As in all parts of life, it is often necessary
to wait one’s turn before having access
to something.
Within a computer system there may be
queues of tasks waiting for the
printer, for access to disk storage etc…
IN COMPUTER APLICATION
COMPUTER APPLICATION EXAMPLES
 Imagine you have a web-site which serves files to
thousands of users. You cannot service all requests, you
can only handle say 100 at once. A fair policy would be
first-come-first serve: serve 100 at a time in order of
arrival. A Queue would definitely be the most appropriate
data structure.
 Similarly in a multitasking operating system, the CPU
cannot run all jobs at once, so jobs must be batched up
and then scheduled according to some policy. Again, a
queue might be a suitable option in this case.
 Say you have a number of documents to be printed at
once. Your OS puts all of these docs in a queue and
sends them to the printer. The printer takes and prints
each document in the order the docs are put in the
queue, ie, First In, First Out.
QUEUE OPERATIONS.
Indeed, we need to perform two operations with
queues:
append (or enqueue) - put an entry to the
queue, and
serve (also called delete or dequeue) -
remove an entry from the queue.
The entry in a queue ready to be served, that is, the
first entry that will be removed from the queue, is
called the front of the queue(or, sometimes, the
head of the queue).
Similarly, the last entry in the queue, that is, the one
most recently added, is called the rear (or the tail ) of
the queue.
STACK — ELEMENTS ARE PULLED IN LAST-IN
FIRST-OUT-ORDER (E.G. A STACK OF PAPERS)
QUEUE — ELEMENTS ARE PULLED IN FIRST-IN
FIRST-OUT-ORDER (E.G. A LINE IN A CAFETERIA)
A Graphic Model of a Queue
HOW HEAD AND TAIL CHANGE
Queue operation
RECAP
 It is a list in which all additions to the list are
made at one end, and all deletions from the
list are made at the other end.
 Say you have a number of documents to be
printed at once. Your OS puts all of these
docs in a queue and sends them to the
printer. The printer takes and prints each
document in the order the docs are put in the
queue, ie, First In, First Out.
TO PREPARE FOR NEXT SESSION
 Stack
 Operations on a stack
 Differences between queues and stack

Más contenido relacionado

La actualidad más candente

heap Sort Algorithm
heap  Sort Algorithmheap  Sort Algorithm
heap Sort AlgorithmLemia Algmri
 
Binary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of AlgorithmsBinary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of AlgorithmsDrishti Bhalla
 
Data Structure and Algorithms Binary Search Tree
Data Structure and Algorithms Binary Search TreeData Structure and Algorithms Binary Search Tree
Data Structure and Algorithms Binary Search TreeManishPrajapati78
 
Queue in Data Structure
Queue in Data Structure Queue in Data Structure
Queue in Data Structure Janki Shah
 
Java Linked List Tutorial | Edureka
Java Linked List Tutorial |  EdurekaJava Linked List Tutorial |  Edureka
Java Linked List Tutorial | EdurekaEdureka!
 
Insertion sort
Insertion sortInsertion sort
Insertion sortalmaqboli
 
Priority Queue in Data Structure
Priority Queue in Data StructurePriority Queue in Data Structure
Priority Queue in Data StructureMeghaj Mallick
 
Circular link list.ppt
Circular link list.pptCircular link list.ppt
Circular link list.pptTirthika Bandi
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data StructureZidny Nafan
 
Introduction to stack
Introduction to stackIntroduction to stack
Introduction to stackvaibhav2910
 
Data structure and algorithm using java
Data structure and algorithm using javaData structure and algorithm using java
Data structure and algorithm using javaNarayan Sau
 
SEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMSSEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMSGokul Hari
 

La actualidad más candente (20)

heap Sort Algorithm
heap  Sort Algorithmheap  Sort Algorithm
heap Sort Algorithm
 
Searching algorithms
Searching algorithmsSearching algorithms
Searching algorithms
 
Binary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of AlgorithmsBinary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of Algorithms
 
Linked list
Linked listLinked list
Linked list
 
Data Structure and Algorithms Binary Search Tree
Data Structure and Algorithms Binary Search TreeData Structure and Algorithms Binary Search Tree
Data Structure and Algorithms Binary Search Tree
 
Stack and Queue
Stack and Queue Stack and Queue
Stack and Queue
 
Queue
QueueQueue
Queue
 
Tree - Data Structure
Tree - Data StructureTree - Data Structure
Tree - Data Structure
 
Queue in Data Structure
Queue in Data Structure Queue in Data Structure
Queue in Data Structure
 
Java Linked List Tutorial | Edureka
Java Linked List Tutorial |  EdurekaJava Linked List Tutorial |  Edureka
Java Linked List Tutorial | Edureka
 
Insertion sort
Insertion sortInsertion sort
Insertion sort
 
Priority Queue in Data Structure
Priority Queue in Data StructurePriority Queue in Data Structure
Priority Queue in Data Structure
 
Circular link list.ppt
Circular link list.pptCircular link list.ppt
Circular link list.ppt
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data Structure
 
stack & queue
stack & queuestack & queue
stack & queue
 
Introduction to stack
Introduction to stackIntroduction to stack
Introduction to stack
 
Data structure and algorithm using java
Data structure and algorithm using javaData structure and algorithm using java
Data structure and algorithm using java
 
SEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMSSEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMS
 
Data structure by Digvijay
Data structure by DigvijayData structure by Digvijay
Data structure by Digvijay
 
Stack a Data Structure
Stack a Data StructureStack a Data Structure
Stack a Data Structure
 

Similar a Data Structures Queue Intro

Lesson 4 - Queue ADT.pdf
Lesson 4 - Queue ADT.pdfLesson 4 - Queue ADT.pdf
Lesson 4 - Queue ADT.pdfLeandroJrErcia
 
Stack and Queue by M.Gomathi Lecturer
Stack and Queue by M.Gomathi LecturerStack and Queue by M.Gomathi Lecturer
Stack and Queue by M.Gomathi Lecturergomathi chlm
 
Write a program in C or C++ which simulates CPU scheduling in an opera.pdf
Write a program in C or C++ which simulates CPU scheduling in an opera.pdfWrite a program in C or C++ which simulates CPU scheduling in an opera.pdf
Write a program in C or C++ which simulates CPU scheduling in an opera.pdfsravi07
 
Mastering Python lesson 5a_lists_list_operations
Mastering Python lesson 5a_lists_list_operationsMastering Python lesson 5a_lists_list_operations
Mastering Python lesson 5a_lists_list_operationsRuth Marvin
 
Bedtime Stories on Operating Systems.pdf
Bedtime Stories on Operating Systems.pdfBedtime Stories on Operating Systems.pdf
Bedtime Stories on Operating Systems.pdfAyushBaiswar1
 
Buffer overflow attacks
Buffer overflow attacksBuffer overflow attacks
Buffer overflow attacksSandun Perera
 
15. Computer Systems Basic Software 1
15. Computer Systems   Basic Software 115. Computer Systems   Basic Software 1
15. Computer Systems Basic Software 1New Era University
 
Data structure Assignment Help
Data structure Assignment HelpData structure Assignment Help
Data structure Assignment HelpJosephErin
 

Similar a Data Structures Queue Intro (20)

stack.ppt
stack.pptstack.ppt
stack.ppt
 
Data Structures - Lecture 6 [queues]
Data Structures - Lecture 6 [queues]Data Structures - Lecture 6 [queues]
Data Structures - Lecture 6 [queues]
 
Lesson 4 - Queue ADT.pdf
Lesson 4 - Queue ADT.pdfLesson 4 - Queue ADT.pdf
Lesson 4 - Queue ADT.pdf
 
Stack and Queue by M.Gomathi Lecturer
Stack and Queue by M.Gomathi LecturerStack and Queue by M.Gomathi Lecturer
Stack and Queue by M.Gomathi Lecturer
 
Data Structures
Data StructuresData Structures
Data Structures
 
Write a program in C or C++ which simulates CPU scheduling in an opera.pdf
Write a program in C or C++ which simulates CPU scheduling in an opera.pdfWrite a program in C or C++ which simulates CPU scheduling in an opera.pdf
Write a program in C or C++ which simulates CPU scheduling in an opera.pdf
 
Intro ds
Intro dsIntro ds
Intro ds
 
TSAT Presentation1.pptx
TSAT Presentation1.pptxTSAT Presentation1.pptx
TSAT Presentation1.pptx
 
Mastering Python lesson 5a_lists_list_operations
Mastering Python lesson 5a_lists_list_operationsMastering Python lesson 5a_lists_list_operations
Mastering Python lesson 5a_lists_list_operations
 
Ch-8.pdf
Ch-8.pdfCh-8.pdf
Ch-8.pdf
 
Bedtime Stories on Operating Systems.pdf
Bedtime Stories on Operating Systems.pdfBedtime Stories on Operating Systems.pdf
Bedtime Stories on Operating Systems.pdf
 
Bt0065
Bt0065Bt0065
Bt0065
 
B T0065
B T0065B T0065
B T0065
 
Bt0070
Bt0070Bt0070
Bt0070
 
Stack & Queue
Stack & QueueStack & Queue
Stack & Queue
 
Buffer overflow attacks
Buffer overflow attacksBuffer overflow attacks
Buffer overflow attacks
 
15. Computer Systems Basic Software 1
15. Computer Systems   Basic Software 115. Computer Systems   Basic Software 1
15. Computer Systems Basic Software 1
 
Disk Scheduling In Operating System.pptx
Disk Scheduling In Operating System.pptxDisk Scheduling In Operating System.pptx
Disk Scheduling In Operating System.pptx
 
Tpl dataflow
Tpl dataflowTpl dataflow
Tpl dataflow
 
Data structure Assignment Help
Data structure Assignment HelpData structure Assignment Help
Data structure Assignment Help
 

Más de Buxoo Abdullah

CODING WITH PYTHON PART 1
CODING WITH PYTHON PART 1CODING WITH PYTHON PART 1
CODING WITH PYTHON PART 1Buxoo Abdullah
 
2.1.1 PROBLEM SOLVING & DESIGN
2.1.1 PROBLEM SOLVING & DESIGN2.1.1 PROBLEM SOLVING & DESIGN
2.1.1 PROBLEM SOLVING & DESIGNBuxoo Abdullah
 
COMPUTER SCIENCE PRE RELEASE 2210 FOR NOVEMBER 2018 P22
COMPUTER SCIENCE PRE RELEASE  2210 FOR NOVEMBER 2018 P22COMPUTER SCIENCE PRE RELEASE  2210 FOR NOVEMBER 2018 P22
COMPUTER SCIENCE PRE RELEASE 2210 FOR NOVEMBER 2018 P22Buxoo Abdullah
 
Computer health & safety issues
Computer health & safety issuesComputer health & safety issues
Computer health & safety issuesBuxoo Abdullah
 
Program & language generation
Program & language generationProgram & language generation
Program & language generationBuxoo Abdullah
 
Formative & summative evaluation
Formative & summative evaluationFormative & summative evaluation
Formative & summative evaluationBuxoo Abdullah
 

Más de Buxoo Abdullah (14)

1.1.2 HEXADECIMAL
1.1.2 HEXADECIMAL1.1.2 HEXADECIMAL
1.1.2 HEXADECIMAL
 
MONEY & BANKING
MONEY & BANKINGMONEY & BANKING
MONEY & BANKING
 
Retail trade
Retail tradeRetail trade
Retail trade
 
1.1.3 DATA STORAGE
1.1.3 DATA STORAGE1.1.3 DATA STORAGE
1.1.3 DATA STORAGE
 
CODING WITH PYTHON PART 1
CODING WITH PYTHON PART 1CODING WITH PYTHON PART 1
CODING WITH PYTHON PART 1
 
2.1.1 PROBLEM SOLVING & DESIGN
2.1.1 PROBLEM SOLVING & DESIGN2.1.1 PROBLEM SOLVING & DESIGN
2.1.1 PROBLEM SOLVING & DESIGN
 
1.1.1 BINARY SYSTEM
1.1.1 BINARY SYSTEM1.1.1 BINARY SYSTEM
1.1.1 BINARY SYSTEM
 
COMPUTER SCIENCE PRE RELEASE 2210 FOR NOVEMBER 2018 P22
COMPUTER SCIENCE PRE RELEASE  2210 FOR NOVEMBER 2018 P22COMPUTER SCIENCE PRE RELEASE  2210 FOR NOVEMBER 2018 P22
COMPUTER SCIENCE PRE RELEASE 2210 FOR NOVEMBER 2018 P22
 
Computer health & safety issues
Computer health & safety issuesComputer health & safety issues
Computer health & safety issues
 
Program & language generation
Program & language generationProgram & language generation
Program & language generation
 
Data and information
Data and informationData and information
Data and information
 
Computer languages
Computer languagesComputer languages
Computer languages
 
Input devices
Input devicesInput devices
Input devices
 
Formative & summative evaluation
Formative & summative evaluationFormative & summative evaluation
Formative & summative evaluation
 

Último

Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
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
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
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
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 

Último (20)

Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
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
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
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 ...
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
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
 

Data Structures Queue Intro

  • 1. RECAP  Data structure is a particular way of storing and organizing data in a computer so that it can be used efficiently.  Different kinds of data structures are suited to different kinds of applications, and some are highly specialized to specific tasks.  Linear (Array, queue, Linked list and stack)  Non Linear ( tree and graph)
  • 2. INTRODUCTION TO QUEUE In ordinary English, a queue is defined as a waiting line, like a line of people waiting to purchase tickets, where the first person in line is the first person served.
  • 3. REAL LIFE EXAMPLES OF QUEUE ARE: 1. A queue of people at ticket-window: The person who comes first gets the ticket first. The person who is coming last is getting the tickets in last. Therefore, it follows first-in-first-out (FIFO) strategy of queue. 2. Luggage checking machine: Luggage checking machine checks the luggage first that comes first. Therefore, it follows FIFO principle of queue. 3. Patients waiting outside the doctor's clinic: The patient who comes first visits the doctor first, and the patient who comes last visits the doctor last. Therefore, it follows the first-in-first-out (FIFO) strategy of queue.
  • 4. IN COMPUTER APLICATION  For computer applications, we similarly define a queue to be a list in which all additions to the list are made at one end, and all deletions from the list are made at the other end.  Queues are also called first-in, first-out lists , or FIFO for short.
  • 5. As in all parts of life, it is often necessary to wait one’s turn before having access to something. Within a computer system there may be queues of tasks waiting for the printer, for access to disk storage etc… IN COMPUTER APLICATION
  • 6. COMPUTER APPLICATION EXAMPLES  Imagine you have a web-site which serves files to thousands of users. You cannot service all requests, you can only handle say 100 at once. A fair policy would be first-come-first serve: serve 100 at a time in order of arrival. A Queue would definitely be the most appropriate data structure.  Similarly in a multitasking operating system, the CPU cannot run all jobs at once, so jobs must be batched up and then scheduled according to some policy. Again, a queue might be a suitable option in this case.  Say you have a number of documents to be printed at once. Your OS puts all of these docs in a queue and sends them to the printer. The printer takes and prints each document in the order the docs are put in the queue, ie, First In, First Out.
  • 7. QUEUE OPERATIONS. Indeed, we need to perform two operations with queues: append (or enqueue) - put an entry to the queue, and serve (also called delete or dequeue) - remove an entry from the queue. The entry in a queue ready to be served, that is, the first entry that will be removed from the queue, is called the front of the queue(or, sometimes, the head of the queue). Similarly, the last entry in the queue, that is, the one most recently added, is called the rear (or the tail ) of the queue.
  • 8. STACK — ELEMENTS ARE PULLED IN LAST-IN FIRST-OUT-ORDER (E.G. A STACK OF PAPERS) QUEUE — ELEMENTS ARE PULLED IN FIRST-IN FIRST-OUT-ORDER (E.G. A LINE IN A CAFETERIA)
  • 9. A Graphic Model of a Queue
  • 10. HOW HEAD AND TAIL CHANGE
  • 12. RECAP  It is a list in which all additions to the list are made at one end, and all deletions from the list are made at the other end.  Say you have a number of documents to be printed at once. Your OS puts all of these docs in a queue and sends them to the printer. The printer takes and prints each document in the order the docs are put in the queue, ie, First In, First Out.
  • 13. TO PREPARE FOR NEXT SESSION  Stack  Operations on a stack  Differences between queues and stack