SlideShare a Scribd company logo
1 of 9
Our website:- https://pywix.blogspot.com/ Rahul Gupta Sir
Our Youtube Channel :- https://www.youtube.com/DigitalClasses
DIGITAL CLASSES
DATA STRUCTURE
QUEUE
 A Queue is a linear structure which
follows a particular order in which
the operations are performed. The
order is First In First Out (FIFO).
 In a queue, one end is always used to
insert data (enqueue) and the other
is used to delete data (dequeue),
because queue is open at both its
ends.
Our website:- https://pywix.blogspot.com/ Rahul Gupta Sir
Our Youtube Channel :- https://www.youtube.com/DigitalClasses
DIGITAL CLASSES
DATA STRUCTURE
QUEUE
 A Queue is a linear structure which
follows a particular order in which
the operations are performed. The
order is First In First Out (FIFO).
 In a queue, one end is always used to
insert data (enqueue) and the other
is used to delete data (dequeue),
because queue is open at both its
ends.
Our website:- https://pywix.blogspot.com/ Rahul Gupta Sir
Our Youtube Channel :- https://www.youtube.com/DigitalClasses
DIGITAL CLASSES
DATA STRUCTURE
QUEUE
 A Queue is a linear structure which
follows a particular order in which
the operations are performed. The
order is First In First Out (FIFO).
 In a queue, one end is always used to
insert data (enqueue) and the other
is used to delete data (dequeue),
because queue is open at both its
ends.
Our website:- https://pywix.blogspot.com/ Rahul Gupta Sir
Our Youtube Channel :- https://www.youtube.com/DigitalClasses
 Queue is an abstract data structure,
somewhat similar to Stacks. Unlike
stacks, a queue is open at both its
ends.
 For example, people waiting in line
for a rail ticket form a queue.
Our website:- https://pywix.blogspot.com/ Rahul Gupta Sir
Our Youtube Channel :- https://www.youtube.com/DigitalClasses
Basic Operations
 enqueue() − add (store) an item to
the queue.
 dequeue() − remove (access) an item
from the queue.
 peek() − Gets the element at the
front of the queue without removing
it.
 isfull() − Checks if the queue is full.
 isempty() − Checks if the queue is
empty.
Note:- In queue, we always dequeue (or
access) data, pointed by front pointer
and while enqueing (or storing) data in
the queue we take help of rear pointer.
Our website:- https://pywix.blogspot.com/ Rahul Gupta Sir
Our Youtube Channel :- https://www.youtube.com/DigitalClasses
Enqueue Operation
Queues maintain two data pointers,
front and rear. Therefore, its operations
are comparatively difficult to implement
than that of stacks.
The following steps should be taken to
enqueue (insert) data into a queue −
Step 1 − Check if the queue is full.
Step 2 − If the queue is full, produce
overflow error and exit.
Step 3 − If the queue is not full,
increment rear pointer to point the next
empty space.
Our website:- https://pywix.blogspot.com/ Rahul Gupta Sir
Our Youtube Channel :- https://www.youtube.com/DigitalClasses
Step 4 − Add data element to the queue
location, where the rear is pointing.
Step 5 − return success.
Our website:- https://pywix.blogspot.com/ Rahul Gupta Sir
Our Youtube Channel :- https://www.youtube.com/DigitalClasses
Algorithm for enqueue operation
procedure enqueue(data)
if queue is full
return overflow
endif
rear ← rear + 1
queue[rear] ← data
return true
end procedure
Dequeue Operation
Accessing data from the queue is a
process of two tasks − access the data
where front is pointing and remove the
data after access. The following steps
Our website:- https://pywix.blogspot.com/ Rahul Gupta Sir
Our Youtube Channel :- https://www.youtube.com/DigitalClasses
are taken to perform dequeue operation
−
Step 1 − Check if the queue is empty.
Step 2 − If the queue is empty, produce
underflow error and exit.
Step 3 − If the queue is not empty,
access the data where front is pointing.
Step 4 − Increment front pointer to point
to the next available data element.
Step 5 − Return success.
Our website:- https://pywix.blogspot.com/ Rahul Gupta Sir
Our Youtube Channel :- https://www.youtube.com/DigitalClasses
Our website:- https://pywix.blogspot.com/ Rahul Gupta Sir
Our Youtube Channel :- https://www.youtube.com/DigitalClasses
Algorithm for dequeue operation
procedure dequeue
if queue is empty
return underflow
end if
data = queue[front]
front ← front + 1
return true
end procedure

More Related Content

Similar to Queue in data structure

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 QueueBalwant Gorad
 
stack and queue array implementation, java.
stack and queue array implementation, java.stack and queue array implementation, java.
stack and queue array implementation, java.CIIT Atd.
 
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.CIIT Atd.
 
Data structure , stack , queue
Data structure , stack , queueData structure , stack , queue
Data structure , stack , queueRajkiran Nadar
 
Unit ii linear data structures
Unit ii linear data structures Unit ii linear data structures
Unit ii linear data structures LavanyaJ28
 
Algorithm and Data Structure - Queue
Algorithm and Data Structure - QueueAlgorithm and Data Structure - Queue
Algorithm and Data Structure - QueueAndiNurkholis1
 
Difference between stack and queue
Difference between stack and queueDifference between stack and queue
Difference between stack and queuePulkitmodi1998
 
Basic Queue Operation in DataStructure.pptx
Basic Queue Operation in DataStructure.pptxBasic Queue Operation in DataStructure.pptx
Basic Queue Operation in DataStructure.pptxLakshmiSamivel
 
Unit ii linear data structures
Unit ii linear data structures Unit ii linear data structures
Unit ii linear data structures LavanyaJ28
 
QUEUE PPT BY KULJIT SINGH.pptx
QUEUE PPT BY KULJIT SINGH.pptxQUEUE PPT BY KULJIT SINGH.pptx
QUEUE PPT BY KULJIT SINGH.pptxTajBir4
 
Data Pipelines - Big Data meets Salesforce
Data Pipelines - Big Data meets SalesforceData Pipelines - Big Data meets Salesforce
Data Pipelines - Big Data meets Salesforceagarciaodeian
 
Hashmaps, Stacks and Queues by Chidera Anichebe.pdf
Hashmaps, Stacks and Queues by Chidera Anichebe.pdfHashmaps, Stacks and Queues by Chidera Anichebe.pdf
Hashmaps, Stacks and Queues by Chidera Anichebe.pdfChideraAnichebe
 
Stacks
StacksStacks
StacksAcad
 

Similar to Queue in data structure (20)

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
 
Stack and queue
Stack and queueStack and queue
Stack and queue
 
stack and queue array implementation, java.
stack and queue array implementation, java.stack and queue array implementation, java.
stack and queue array implementation, java.
 
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.
 
Data structure , stack , queue
Data structure , stack , queueData structure , stack , queue
Data structure , stack , queue
 
Unit ii linear data structures
Unit ii linear data structures Unit ii linear data structures
Unit ii linear data structures
 
Recommender Infrastructure in Kumparan
Recommender Infrastructure in KumparanRecommender Infrastructure in Kumparan
Recommender Infrastructure in Kumparan
 
Algorithm and Data Structure - Queue
Algorithm and Data Structure - QueueAlgorithm and Data Structure - Queue
Algorithm and Data Structure - Queue
 
Difference between stack and queue
Difference between stack and queueDifference between stack and queue
Difference between stack and queue
 
Data Structures
Data StructuresData Structures
Data Structures
 
Queue
QueueQueue
Queue
 
Basic Queue Operation in DataStructure.pptx
Basic Queue Operation in DataStructure.pptxBasic Queue Operation in DataStructure.pptx
Basic Queue Operation in DataStructure.pptx
 
Unit ii linear data structures
Unit ii linear data structures Unit ii linear data structures
Unit ii linear data structures
 
QUEUE PPT BY KULJIT SINGH.pptx
QUEUE PPT BY KULJIT SINGH.pptxQUEUE PPT BY KULJIT SINGH.pptx
QUEUE PPT BY KULJIT SINGH.pptx
 
Data Pipelines - Big Data meets Salesforce
Data Pipelines - Big Data meets SalesforceData Pipelines - Big Data meets Salesforce
Data Pipelines - Big Data meets Salesforce
 
Scipy, numpy and friends
Scipy, numpy and friendsScipy, numpy and friends
Scipy, numpy and friends
 
Stack
StackStack
Stack
 
Hashmaps, Stacks and Queues by Chidera Anichebe.pdf
Hashmaps, Stacks and Queues by Chidera Anichebe.pdfHashmaps, Stacks and Queues by Chidera Anichebe.pdf
Hashmaps, Stacks and Queues by Chidera Anichebe.pdf
 
Queue
QueueQueue
Queue
 
Stacks
StacksStacks
Stacks
 

More from Rahul Gupta

LINKED LIST.pptx
LINKED LIST.pptxLINKED LIST.pptx
LINKED LIST.pptxRahul Gupta
 
COMPUTER VOCATIONAL PHP THIRD YEAR MGSU PREVIOUS YEAR PAPER2020
COMPUTER VOCATIONAL PHP THIRD YEAR  MGSU PREVIOUS YEAR PAPER2020COMPUTER VOCATIONAL PHP THIRD YEAR  MGSU PREVIOUS YEAR PAPER2020
COMPUTER VOCATIONAL PHP THIRD YEAR MGSU PREVIOUS YEAR PAPER2020Rahul Gupta
 
Class 8th Formula Sheet | CBSE | NCERT
Class 8th Formula Sheet | CBSE | NCERTClass 8th Formula Sheet | CBSE | NCERT
Class 8th Formula Sheet | CBSE | NCERTRahul Gupta
 
Class 10th maths formula sheet
Class 10th maths formula sheetClass 10th maths formula sheet
Class 10th maths formula sheetRahul Gupta
 
A star algorithm in artificial intelligence
A star algorithm in artificial intelligenceA star algorithm in artificial intelligence
A star algorithm in artificial intelligenceRahul Gupta
 
Best first search algorithm in Artificial Intelligence
Best first search algorithm in Artificial IntelligenceBest first search algorithm in Artificial Intelligence
Best first search algorithm in Artificial IntelligenceRahul Gupta
 
hill climbing algorithm in artificial intelligence
hill climbing algorithm in artificial intelligencehill climbing algorithm in artificial intelligence
hill climbing algorithm in artificial intelligenceRahul Gupta
 

More from Rahul Gupta (9)

LINKED LIST.pptx
LINKED LIST.pptxLINKED LIST.pptx
LINKED LIST.pptx
 
TAUTOLOGY.pptx
TAUTOLOGY.pptxTAUTOLOGY.pptx
TAUTOLOGY.pptx
 
COMPUTER VOCATIONAL PHP THIRD YEAR MGSU PREVIOUS YEAR PAPER2020
COMPUTER VOCATIONAL PHP THIRD YEAR  MGSU PREVIOUS YEAR PAPER2020COMPUTER VOCATIONAL PHP THIRD YEAR  MGSU PREVIOUS YEAR PAPER2020
COMPUTER VOCATIONAL PHP THIRD YEAR MGSU PREVIOUS YEAR PAPER2020
 
Class 8th Formula Sheet | CBSE | NCERT
Class 8th Formula Sheet | CBSE | NCERTClass 8th Formula Sheet | CBSE | NCERT
Class 8th Formula Sheet | CBSE | NCERT
 
Class 10th maths formula sheet
Class 10th maths formula sheetClass 10th maths formula sheet
Class 10th maths formula sheet
 
Expert system
Expert systemExpert system
Expert system
 
A star algorithm in artificial intelligence
A star algorithm in artificial intelligenceA star algorithm in artificial intelligence
A star algorithm in artificial intelligence
 
Best first search algorithm in Artificial Intelligence
Best first search algorithm in Artificial IntelligenceBest first search algorithm in Artificial Intelligence
Best first search algorithm in Artificial Intelligence
 
hill climbing algorithm in artificial intelligence
hill climbing algorithm in artificial intelligencehill climbing algorithm in artificial intelligence
hill climbing algorithm in artificial intelligence
 

Recently uploaded

Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
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
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
“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
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
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
 
Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonJericReyAuditor
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
_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
 
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
 

Recently uploaded (20)

Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
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
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
“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...
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
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
 
Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lesson
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).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
 
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...
 

Queue in data structure

  • 1. Our website:- https://pywix.blogspot.com/ Rahul Gupta Sir Our Youtube Channel :- https://www.youtube.com/DigitalClasses DIGITAL CLASSES DATA STRUCTURE QUEUE  A Queue is a linear structure which follows a particular order in which the operations are performed. The order is First In First Out (FIFO).  In a queue, one end is always used to insert data (enqueue) and the other is used to delete data (dequeue), because queue is open at both its ends. Our website:- https://pywix.blogspot.com/ Rahul Gupta Sir Our Youtube Channel :- https://www.youtube.com/DigitalClasses DIGITAL CLASSES DATA STRUCTURE QUEUE  A Queue is a linear structure which follows a particular order in which the operations are performed. The order is First In First Out (FIFO).  In a queue, one end is always used to insert data (enqueue) and the other is used to delete data (dequeue), because queue is open at both its ends. Our website:- https://pywix.blogspot.com/ Rahul Gupta Sir Our Youtube Channel :- https://www.youtube.com/DigitalClasses DIGITAL CLASSES DATA STRUCTURE QUEUE  A Queue is a linear structure which follows a particular order in which the operations are performed. The order is First In First Out (FIFO).  In a queue, one end is always used to insert data (enqueue) and the other is used to delete data (dequeue), because queue is open at both its ends.
  • 2. Our website:- https://pywix.blogspot.com/ Rahul Gupta Sir Our Youtube Channel :- https://www.youtube.com/DigitalClasses  Queue is an abstract data structure, somewhat similar to Stacks. Unlike stacks, a queue is open at both its ends.  For example, people waiting in line for a rail ticket form a queue.
  • 3. Our website:- https://pywix.blogspot.com/ Rahul Gupta Sir Our Youtube Channel :- https://www.youtube.com/DigitalClasses Basic Operations  enqueue() − add (store) an item to the queue.  dequeue() − remove (access) an item from the queue.  peek() − Gets the element at the front of the queue without removing it.  isfull() − Checks if the queue is full.  isempty() − Checks if the queue is empty. Note:- In queue, we always dequeue (or access) data, pointed by front pointer and while enqueing (or storing) data in the queue we take help of rear pointer.
  • 4. Our website:- https://pywix.blogspot.com/ Rahul Gupta Sir Our Youtube Channel :- https://www.youtube.com/DigitalClasses Enqueue Operation Queues maintain two data pointers, front and rear. Therefore, its operations are comparatively difficult to implement than that of stacks. The following steps should be taken to enqueue (insert) data into a queue − Step 1 − Check if the queue is full. Step 2 − If the queue is full, produce overflow error and exit. Step 3 − If the queue is not full, increment rear pointer to point the next empty space.
  • 5. Our website:- https://pywix.blogspot.com/ Rahul Gupta Sir Our Youtube Channel :- https://www.youtube.com/DigitalClasses Step 4 − Add data element to the queue location, where the rear is pointing. Step 5 − return success.
  • 6. Our website:- https://pywix.blogspot.com/ Rahul Gupta Sir Our Youtube Channel :- https://www.youtube.com/DigitalClasses Algorithm for enqueue operation procedure enqueue(data) if queue is full return overflow endif rear ← rear + 1 queue[rear] ← data return true end procedure Dequeue Operation Accessing data from the queue is a process of two tasks − access the data where front is pointing and remove the data after access. The following steps
  • 7. Our website:- https://pywix.blogspot.com/ Rahul Gupta Sir Our Youtube Channel :- https://www.youtube.com/DigitalClasses are taken to perform dequeue operation − Step 1 − Check if the queue is empty. Step 2 − If the queue is empty, produce underflow error and exit. Step 3 − If the queue is not empty, access the data where front is pointing. Step 4 − Increment front pointer to point to the next available data element. Step 5 − Return success.
  • 8. Our website:- https://pywix.blogspot.com/ Rahul Gupta Sir Our Youtube Channel :- https://www.youtube.com/DigitalClasses
  • 9. Our website:- https://pywix.blogspot.com/ Rahul Gupta Sir Our Youtube Channel :- https://www.youtube.com/DigitalClasses Algorithm for dequeue operation procedure dequeue if queue is empty return underflow end if data = queue[front] front ← front + 1 return true end procedure