SlideShare a Scribd company logo
1 of 14
QUEUE IN DATASTRUCTURE
(BASIC OPERATION)
BY,
LAKSHMI,
ASSISTANT PROFESSOR,
DEPARTMENT OF COMPUTER SCIENCE,
SRI ADI CHUNCHANAGIRI WOMEN’S COLLEGE, CUMBUM.
What is a Queue?
1. A queue can be defined as an ordered list which enables insert operations to be performed at
one end called REAR and delete operations to be performed at another end called FRONT.
• 2. Queue is referred to be as First In First Out list.
• 3. For example, people waiting in line for a rail ticket form a
queue.
Applications of Queue
• Queues are widely used as waiting lists for a single shared resource like printer,
disk, CPU.
• Queues are used in asynchronous transfer of data (where data is not being
transferred at the same rate between two processes) for eg. pipes, file IO, sockets.
• Queues are used as buffers in most of the applications like MP3 media player, CD
player, etc.
• Queue are used to maintain the play list in media players in order to add and
remove the songs from the play-list.
• Queues are used in operating systems for handling interrupts.
Complexity
Data
Structu
re
Time Complexity Space
Compl
eity
Average Worst Worst
Access Search Insertio
n
Deletio
n
Access Search Insertio
n
Deletio
n
Queue θ(n) θ(n) θ(1) θ(1) O(n) O(n) O(1) O(1) O(n)
Basic Operations for Queue in Data Structure
A queue is an object (an abstract data structure - ADT) that allows the following operations:
• Enqueue: Add an element to the end of the queue
• Dequeue: Remove an element from the front of the queue
• IsEmpty: Check if the queue is empty
• IsFull: Check if the queue is full
• Peek: Get the value of the front of the queue without removing it
Enqueue() Operation
The following steps should be followed to insert (enqueue) data element into a
queue -
• Step 1: Check if the queue is full.
• Step 2: If the queue is full, Overflow error.
• Step 3: If the queue is not full, increment the rear pointer to point to the next
available empty space.
• Step 4: Add the data element to the queue location where the rear is pointing.
• Step 5: Here, you have successfully added 7, 2, and -9.
Enqueue() Operation
Dequeue() Operation
Obtaining data from the queue comprises two subtasks: access the data where the
front is pointing and remove the data after access. You should take the following steps
to remove data from the queue -
• Step 1: Check if the queue is empty.
• Step 2: If the queue is empty, Underflow error.
• Step 3: If the queue is not empty, access the data where the front pointer is
pointing.
• Step 4: Increment front pointer to point to the next available data element.
• Step 5: Here, you have removed 7, 2, and -9 from the queue data structure.
Dequeue() Operation
Peek() Operation
This function helps in extracting the data element where the front is pointing without
removing it from the queue. The algorithm of Peek() function is as follows-
• Step 1: Check if the queue is empty.
• Step 2: If the queue is empty, return “Queue is Empty.”
• Step 3: If the queue is not empty, access the data where the front pointer is pointing.
• Step 4: Return data.
isFull() Operation
This function checks if the rear pointer is reached at MAXSIZE to determine that
the queue is full. The following steps are performed in the isFull() operation -
• Step 1: Check if rear == MAXSIZE - 1.
• Step 2: If they are equal, return “Queue is Full.”
• Step 3: If they are not equal, return “Queue is not Full.”
isNull() Operation
The algorithm of the isNull() operation is as follows -
• Step 1: Check if the rear and front are pointing to null memory space, i.e.,
-1.
• Step 2: If they are pointing to -1, return “Queue is empty.”
• Step 3: If they are not equal, return “Queue is not empty.”
Basic Queue Operation in DataStructure.pptx

More Related Content

What's hot (20)

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)
 
Data Structure (Tree)
Data Structure (Tree)Data Structure (Tree)
Data Structure (Tree)
 
Ppt on Linked list,stack,queue
Ppt on Linked list,stack,queuePpt on Linked list,stack,queue
Ppt on Linked list,stack,queue
 
Unit 3 stack
Unit   3 stackUnit   3 stack
Unit 3 stack
 
Expression trees
Expression treesExpression trees
Expression trees
 
Linked list
Linked listLinked list
Linked list
 
Queue ppt
Queue pptQueue ppt
Queue ppt
 
Elementary data organisation
Elementary data organisationElementary data organisation
Elementary data organisation
 
Queues
QueuesQueues
Queues
 
What is Stack, Its Operations, Queue, Circular Queue, Priority Queue
What is Stack, Its Operations, Queue, Circular Queue, Priority QueueWhat is Stack, Its Operations, Queue, Circular Queue, Priority Queue
What is Stack, Its Operations, Queue, Circular Queue, Priority Queue
 
Data structure using c module 2
Data structure using c module 2Data structure using c module 2
Data structure using c module 2
 
STACK ( LIFO STRUCTURE) - Data Structure
STACK ( LIFO STRUCTURE) - Data StructureSTACK ( LIFO STRUCTURE) - Data Structure
STACK ( LIFO STRUCTURE) - Data Structure
 
Linked list
Linked listLinked list
Linked list
 
Threaded Binary Tree
Threaded Binary TreeThreaded Binary Tree
Threaded Binary Tree
 
Lecture 6: linked list
Lecture 6:  linked listLecture 6:  linked list
Lecture 6: linked list
 
Queue in Data Structure
Queue in Data StructureQueue in Data Structure
Queue in Data Structure
 
Data structure stack&queue basics
Data structure stack&queue   basicsData structure stack&queue   basics
Data structure stack&queue basics
 
Presentation on queue
Presentation on queuePresentation on queue
Presentation on queue
 
Circular queue
Circular queueCircular queue
Circular queue
 
Stack a Data Structure
Stack a Data StructureStack a Data Structure
Stack a Data Structure
 

Similar to Basic Queue Operation in DataStructure.pptx

Similar to Basic Queue Operation in DataStructure.pptx (20)

Algorithm and Data Structure - Queue
Algorithm and Data Structure - QueueAlgorithm and Data Structure - Queue
Algorithm and Data Structure - Queue
 
Queue
QueueQueue
Queue
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data Structure
 
queueppt-191018053228 (1).pptx
queueppt-191018053228 (1).pptxqueueppt-191018053228 (1).pptx
queueppt-191018053228 (1).pptx
 
Stack and queue
Stack and queueStack and queue
Stack and queue
 
Unit-ii-Queue ADT.pptx
Unit-ii-Queue ADT.pptxUnit-ii-Queue ADT.pptx
Unit-ii-Queue ADT.pptx
 
Queues
Queues Queues
Queues
 
QUEUE PPT BY KULJIT SINGH.pptx
QUEUE PPT BY KULJIT SINGH.pptxQUEUE PPT BY KULJIT SINGH.pptx
QUEUE PPT BY KULJIT SINGH.pptx
 
Queue and its operations
Queue and its operationsQueue and its operations
Queue and its operations
 
Unit 3 Stacks and Queues.pptx
Unit 3 Stacks and Queues.pptxUnit 3 Stacks and Queues.pptx
Unit 3 Stacks and Queues.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
 
Queues
QueuesQueues
Queues
 
01-Introduction of DSA-1.pptx
01-Introduction of DSA-1.pptx01-Introduction of DSA-1.pptx
01-Introduction of DSA-1.pptx
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data Structure
 
Queues
QueuesQueues
Queues
 
Stack and queue
Stack and queueStack and queue
Stack and queue
 
Data Structures
Data StructuresData Structures
Data Structures
 
unit 5 stack & queue.ppt
unit 5 stack & queue.pptunit 5 stack & queue.ppt
unit 5 stack & queue.ppt
 
VCE Unit 03vv.pptx
VCE Unit 03vv.pptxVCE Unit 03vv.pptx
VCE Unit 03vv.pptx
 
Stacks-and-Queues.pdf
Stacks-and-Queues.pdfStacks-and-Queues.pdf
Stacks-and-Queues.pdf
 

More from LakshmiSamivel

Greedy Algorithm for Computer Science.ppt
Greedy Algorithm for Computer Science.pptGreedy Algorithm for Computer Science.ppt
Greedy Algorithm for Computer Science.pptLakshmiSamivel
 
General methodin Data Structure for UG.pptx
General methodin Data Structure for UG.pptxGeneral methodin Data Structure for UG.pptx
General methodin Data Structure for UG.pptxLakshmiSamivel
 
DIVIDE AND CONQUERMETHOD IN DATASTRUCTURE.pptx
DIVIDE AND CONQUERMETHOD IN DATASTRUCTURE.pptxDIVIDE AND CONQUERMETHOD IN DATASTRUCTURE.pptx
DIVIDE AND CONQUERMETHOD IN DATASTRUCTURE.pptxLakshmiSamivel
 
DataSructure-Time and Space Complexity.pptx
DataSructure-Time and Space Complexity.pptxDataSructure-Time and Space Complexity.pptx
DataSructure-Time and Space Complexity.pptxLakshmiSamivel
 
Classification of datastructure.ppt
Classification of datastructure.pptClassification of datastructure.ppt
Classification of datastructure.pptLakshmiSamivel
 
Computer network notes
Computer network notesComputer network notes
Computer network notesLakshmiSamivel
 

More from LakshmiSamivel (14)

Greedy Algorithm for Computer Science.ppt
Greedy Algorithm for Computer Science.pptGreedy Algorithm for Computer Science.ppt
Greedy Algorithm for Computer Science.ppt
 
General methodin Data Structure for UG.pptx
General methodin Data Structure for UG.pptxGeneral methodin Data Structure for UG.pptx
General methodin Data Structure for UG.pptx
 
DIVIDE AND CONQUERMETHOD IN DATASTRUCTURE.pptx
DIVIDE AND CONQUERMETHOD IN DATASTRUCTURE.pptxDIVIDE AND CONQUERMETHOD IN DATASTRUCTURE.pptx
DIVIDE AND CONQUERMETHOD IN DATASTRUCTURE.pptx
 
DataSructure-Time and Space Complexity.pptx
DataSructure-Time and Space Complexity.pptxDataSructure-Time and Space Complexity.pptx
DataSructure-Time and Space Complexity.pptx
 
Presentation DM.pptx
Presentation DM.pptxPresentation DM.pptx
Presentation DM.pptx
 
Dos.pptx
Dos.pptxDos.pptx
Dos.pptx
 
Formatting tags
Formatting tagsFormatting tags
Formatting tags
 
Classification of datastructure.ppt
Classification of datastructure.pptClassification of datastructure.ppt
Classification of datastructure.ppt
 
Semaphore
Semaphore Semaphore
Semaphore
 
Firewall ppt
Firewall pptFirewall ppt
Firewall ppt
 
View
ViewView
View
 
Procedures andcursors
Procedures andcursorsProcedures andcursors
Procedures andcursors
 
Computer network notes
Computer network notesComputer network notes
Computer network notes
 
OsI reference model
OsI reference modelOsI reference model
OsI reference model
 

Recently uploaded

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
 
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
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
“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
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptxPoojaSen20
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
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
 
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
 
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
 
_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
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
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
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 

Recently uploaded (20)

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
 
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
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
“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...
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptx
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
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
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
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
 
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 ...
 
_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
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
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
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 

Basic Queue Operation in DataStructure.pptx

  • 1. QUEUE IN DATASTRUCTURE (BASIC OPERATION) BY, LAKSHMI, ASSISTANT PROFESSOR, DEPARTMENT OF COMPUTER SCIENCE, SRI ADI CHUNCHANAGIRI WOMEN’S COLLEGE, CUMBUM.
  • 2. What is a Queue? 1. A queue can be defined as an ordered list which enables insert operations to be performed at one end called REAR and delete operations to be performed at another end called FRONT. • 2. Queue is referred to be as First In First Out list. • 3. For example, people waiting in line for a rail ticket form a queue.
  • 3.
  • 4. Applications of Queue • Queues are widely used as waiting lists for a single shared resource like printer, disk, CPU. • Queues are used in asynchronous transfer of data (where data is not being transferred at the same rate between two processes) for eg. pipes, file IO, sockets. • Queues are used as buffers in most of the applications like MP3 media player, CD player, etc. • Queue are used to maintain the play list in media players in order to add and remove the songs from the play-list. • Queues are used in operating systems for handling interrupts.
  • 5. Complexity Data Structu re Time Complexity Space Compl eity Average Worst Worst Access Search Insertio n Deletio n Access Search Insertio n Deletio n Queue θ(n) θ(n) θ(1) θ(1) O(n) O(n) O(1) O(1) O(n)
  • 6. Basic Operations for Queue in Data Structure A queue is an object (an abstract data structure - ADT) that allows the following operations: • Enqueue: Add an element to the end of the queue • Dequeue: Remove an element from the front of the queue • IsEmpty: Check if the queue is empty • IsFull: Check if the queue is full • Peek: Get the value of the front of the queue without removing it
  • 7. Enqueue() Operation The following steps should be followed to insert (enqueue) data element into a queue - • Step 1: Check if the queue is full. • Step 2: If the queue is full, Overflow error. • Step 3: If the queue is not full, increment the rear pointer to point to the next available empty space. • Step 4: Add the data element to the queue location where the rear is pointing. • Step 5: Here, you have successfully added 7, 2, and -9.
  • 9. Dequeue() Operation Obtaining data from the queue comprises two subtasks: access the data where the front is pointing and remove the data after access. You should take the following steps to remove data from the queue - • Step 1: Check if the queue is empty. • Step 2: If the queue is empty, Underflow error. • Step 3: If the queue is not empty, access the data where the front pointer is pointing. • Step 4: Increment front pointer to point to the next available data element. • Step 5: Here, you have removed 7, 2, and -9 from the queue data structure.
  • 11. Peek() Operation This function helps in extracting the data element where the front is pointing without removing it from the queue. The algorithm of Peek() function is as follows- • Step 1: Check if the queue is empty. • Step 2: If the queue is empty, return “Queue is Empty.” • Step 3: If the queue is not empty, access the data where the front pointer is pointing. • Step 4: Return data.
  • 12. isFull() Operation This function checks if the rear pointer is reached at MAXSIZE to determine that the queue is full. The following steps are performed in the isFull() operation - • Step 1: Check if rear == MAXSIZE - 1. • Step 2: If they are equal, return “Queue is Full.” • Step 3: If they are not equal, return “Queue is not Full.”
  • 13. isNull() Operation The algorithm of the isNull() operation is as follows - • Step 1: Check if the rear and front are pointing to null memory space, i.e., -1. • Step 2: If they are pointing to -1, return “Queue is empty.” • Step 3: If they are not equal, return “Queue is not empty.”