際際滷

際際滷Share a Scribd company logo
QUEUE IN DATASTRUCTURE
(BASIC OPERATION)
BY,
LAKSHMI,
ASSISTANT PROFESSOR,
DEPARTMENT OF COMPUTER SCIENCE,
SRI ADI CHUNCHANAGIRI WOMENS 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.
Basic Queue Operation in DataStructure.pptx
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
Ad

Recommended

Informatica forense
Leidy Johana Garcia Ortiz
Dise単o de una red LAN.
angelawrsnp
Queue and its operations
Queue and its operations
V.V.Vanniaperumal College for Women
Lab 07 (2).pdfbdvdyve dhdysbsnjsnsvdvydbdns
Lab 07 (2).pdfbdvdyve dhdysbsnjsnsvdvydbdns
playstore9ha
queue.pptx
queue.pptx
Dr.Shweta
Data structures
Data structures
naveeth babu
DS ppt1.pptx.c programing. Engineering. Data structure
DS ppt1.pptx.c programing. Engineering. Data structure
dibyajyotijena05
Queue
Queue
pooja kumari
Queues
Queues
maamir farooq
Data Structures and Algorithms-DSA_Linkedlist_class 7.pdf
Data Structures and Algorithms-DSA_Linkedlist_class 7.pdf
Chethan Raddi
Queues
Queues
nidhisatija1
Queue
Queue
Ayaz Akhtar
Queue ppt
Queue ppt
SouravKumar328
Queues_0748555555555555555555555526.pptx
Queues_0748555555555555555555555526.pptx
nailapp2023
Stack and queue
Stack and queue
CHANDAN KUMAR
@Chapter 4 DSA Part II.pptx
@Chapter 4 DSA Part II.pptx
NuraMohamed9
Data Structures - Lecture 6 [queues]
Data Structures - Lecture 6 [queues]
Muhammad Hammad Waseem
Queue Data Structure
Queue Data Structure
Afaq Mansoor Khan
Polynomialmotilalanehrunationalinstitute.pdf
Polynomialmotilalanehrunationalinstitute.pdf
yugpadhiyar2006
Stacks-and-Queues.pdf
Stacks-and-Queues.pdf
TobyWtf
VCE Unit 03vv.pptx
VCE Unit 03vv.pptx
skilljiolms
queueppt-191018053228 (1).pptx
queueppt-191018053228 (1).pptx
MeghaKulkarni27
Queue
Queue
Sonali Soni
Algo>Queues
Algo>Queues
Ain-ul-Moiz Khawaja
Queue in data structure
Queue in data structure
Rahul Gupta
Basic Terminologies of Queue...Basic operations on Queue
Basic Terminologies of Queue...Basic operations on Queue
arpitasen55
Queue by rajanikanth
Queue by rajanikanth
btechsmartclass
Lecture 2d queues
Lecture 2d queues
Victor Palmar
Greedy Algorithm for Computer Science.ppt
Greedy Algorithm for Computer Science.ppt
LakshmiSamivel
General methodin Data Structure for UG.pptx
General methodin Data Structure for UG.pptx
LakshmiSamivel

More Related Content

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

Queues
Queues
maamir farooq
Data Structures and Algorithms-DSA_Linkedlist_class 7.pdf
Data Structures and Algorithms-DSA_Linkedlist_class 7.pdf
Chethan Raddi
Queues
Queues
nidhisatija1
Queue
Queue
Ayaz Akhtar
Queue ppt
Queue ppt
SouravKumar328
Queues_0748555555555555555555555526.pptx
Queues_0748555555555555555555555526.pptx
nailapp2023
Stack and queue
Stack and queue
CHANDAN KUMAR
@Chapter 4 DSA Part II.pptx
@Chapter 4 DSA Part II.pptx
NuraMohamed9
Data Structures - Lecture 6 [queues]
Data Structures - Lecture 6 [queues]
Muhammad Hammad Waseem
Queue Data Structure
Queue Data Structure
Afaq Mansoor Khan
Polynomialmotilalanehrunationalinstitute.pdf
Polynomialmotilalanehrunationalinstitute.pdf
yugpadhiyar2006
Stacks-and-Queues.pdf
Stacks-and-Queues.pdf
TobyWtf
VCE Unit 03vv.pptx
VCE Unit 03vv.pptx
skilljiolms
queueppt-191018053228 (1).pptx
queueppt-191018053228 (1).pptx
MeghaKulkarni27
Queue
Queue
Sonali Soni
Algo>Queues
Algo>Queues
Ain-ul-Moiz Khawaja
Queue in data structure
Queue in data structure
Rahul Gupta
Basic Terminologies of Queue...Basic operations on Queue
Basic Terminologies of Queue...Basic operations on Queue
arpitasen55
Queue by rajanikanth
Queue by rajanikanth
btechsmartclass
Lecture 2d queues
Lecture 2d queues
Victor Palmar
Data Structures and Algorithms-DSA_Linkedlist_class 7.pdf
Data Structures and Algorithms-DSA_Linkedlist_class 7.pdf
Chethan Raddi
Queues_0748555555555555555555555526.pptx
Queues_0748555555555555555555555526.pptx
nailapp2023
@Chapter 4 DSA Part II.pptx
@Chapter 4 DSA Part II.pptx
NuraMohamed9
Data Structures - Lecture 6 [queues]
Data Structures - Lecture 6 [queues]
Muhammad Hammad Waseem
Polynomialmotilalanehrunationalinstitute.pdf
Polynomialmotilalanehrunationalinstitute.pdf
yugpadhiyar2006
Stacks-and-Queues.pdf
Stacks-and-Queues.pdf
TobyWtf
VCE Unit 03vv.pptx
VCE Unit 03vv.pptx
skilljiolms
queueppt-191018053228 (1).pptx
queueppt-191018053228 (1).pptx
MeghaKulkarni27
Queue in data structure
Queue in data structure
Rahul Gupta
Basic Terminologies of Queue...Basic operations on Queue
Basic Terminologies of Queue...Basic operations on Queue
arpitasen55
Lecture 2d queues
Lecture 2d queues
Victor Palmar

More from LakshmiSamivel (15)

Greedy Algorithm for Computer Science.ppt
Greedy Algorithm for Computer Science.ppt
LakshmiSamivel
General methodin Data Structure for UG.pptx
General methodin Data Structure for UG.pptx
LakshmiSamivel
DIVIDE AND CONQUERMETHOD IN DATASTRUCTURE.pptx
DIVIDE AND CONQUERMETHOD IN DATASTRUCTURE.pptx
LakshmiSamivel
DataSructure-Time and Space Complexity.pptx
DataSructure-Time and Space Complexity.pptx
LakshmiSamivel
Presentation DM.pptx
Presentation DM.pptx
LakshmiSamivel
Dos.pptx
Dos.pptx
LakshmiSamivel
Formatting tags
Formatting tags
LakshmiSamivel
Classification of datastructure.ppt
Classification of datastructure.ppt
LakshmiSamivel
Top down parsing
Top down parsing
LakshmiSamivel
Semaphore
Semaphore
LakshmiSamivel
Firewall ppt
Firewall ppt
LakshmiSamivel
View
View
LakshmiSamivel
Procedures andcursors
Procedures andcursors
LakshmiSamivel
Computer network notes
Computer network notes
LakshmiSamivel
OsI reference model
OsI reference model
LakshmiSamivel
Greedy Algorithm for Computer Science.ppt
Greedy Algorithm for Computer Science.ppt
LakshmiSamivel
General methodin Data Structure for UG.pptx
General methodin Data Structure for UG.pptx
LakshmiSamivel
DIVIDE AND CONQUERMETHOD IN DATASTRUCTURE.pptx
DIVIDE AND CONQUERMETHOD IN DATASTRUCTURE.pptx
LakshmiSamivel
DataSructure-Time and Space Complexity.pptx
DataSructure-Time and Space Complexity.pptx
LakshmiSamivel
Presentation DM.pptx
Presentation DM.pptx
LakshmiSamivel
Classification of datastructure.ppt
Classification of datastructure.ppt
LakshmiSamivel
Procedures andcursors
Procedures andcursors
LakshmiSamivel
Computer network notes
Computer network notes
LakshmiSamivel
OsI reference model
OsI reference model
LakshmiSamivel
Ad

Recently uploaded (20)

Paper 107 | From Watchdog to Lapdog: Ishiguros Fiction and the Rise of Godi...
Paper 107 | From Watchdog to Lapdog: Ishiguros Fiction and the Rise of Godi...
Rajdeep Bavaliya
june 10 2025 ppt for madden on art science is over.pptx
june 10 2025 ppt for madden on art science is over.pptx
roger malina
Ray Dalio How Countries go Broke the Big Cycle
Ray Dalio How Countries go Broke the Big Cycle
Dadang Solihin
Chalukyas of Gujrat, Solanki Dynasty NEP.pptx
Chalukyas of Gujrat, Solanki Dynasty NEP.pptx
Dr. Ravi Shankar Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
How to Configure Vendor Management in Lunch App of Odoo 18
How to Configure Vendor Management in Lunch App of Odoo 18
Celine George
SPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptx
SPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptx
Sourav Kr Podder
What are the benefits that dance brings?
What are the benefits that dance brings?
memi27
Introduction to Generative AI and Copilot.pdf
Introduction to Generative AI and Copilot.pdf
TechSoup
BINARY files CSV files JSON files with example.pptx
BINARY files CSV files JSON files with example.pptx
Ramakrishna Reddy Bijjam
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
razelitouali
ABCs of Bookkeeping for Nonprofits TechSoup.pdf
ABCs of Bookkeeping for Nonprofits TechSoup.pdf
TechSoup
Plate Tectonic Boundaries and Continental Drift Theory
Plate Tectonic Boundaries and Continental Drift Theory
Marie
Wax Moon, Richmond, VA. Terrence McPherson
Wax Moon, Richmond, VA. Terrence McPherson
TerrenceMcPherson1
Non-Communicable Diseases and National Health Programs Unit 10 | B.Sc Nursi...
Non-Communicable Diseases and National Health Programs Unit 10 | B.Sc Nursi...
RAKESH SAJJAN
GEOGRAPHY-Study Material [ Class 10th] .pdf
GEOGRAPHY-Study Material [ Class 10th] .pdf
SHERAZ AHMAD LONE
Paper 109 | Archetypal Journeys in Interstellar: Exploring Universal Themes...
Paper 109 | Archetypal Journeys in Interstellar: Exploring Universal Themes...
Rajdeep Bavaliya
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Pragya - UEM Kolkata Quiz Club
How to Manage Multi Language for Invoice in Odoo 18
How to Manage Multi Language for Invoice in Odoo 18
Celine George
FIRST DAY HIGH orientation for mapeh subject in grade 10.pptx
FIRST DAY HIGH orientation for mapeh subject in grade 10.pptx
GlysdiEelesor1
How to Manage Inventory Movement in Odoo 18 POS
How to Manage Inventory Movement in Odoo 18 POS
Celine George
Paper 107 | From Watchdog to Lapdog: Ishiguros Fiction and the Rise of Godi...
Paper 107 | From Watchdog to Lapdog: Ishiguros Fiction and the Rise of Godi...
Rajdeep Bavaliya
june 10 2025 ppt for madden on art science is over.pptx
june 10 2025 ppt for madden on art science is over.pptx
roger malina
Ray Dalio How Countries go Broke the Big Cycle
Ray Dalio How Countries go Broke the Big Cycle
Dadang Solihin
How to Configure Vendor Management in Lunch App of Odoo 18
How to Configure Vendor Management in Lunch App of Odoo 18
Celine George
SPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptx
SPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptx
Sourav Kr Podder
What are the benefits that dance brings?
What are the benefits that dance brings?
memi27
Introduction to Generative AI and Copilot.pdf
Introduction to Generative AI and Copilot.pdf
TechSoup
BINARY files CSV files JSON files with example.pptx
BINARY files CSV files JSON files with example.pptx
Ramakrishna Reddy Bijjam
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
razelitouali
ABCs of Bookkeeping for Nonprofits TechSoup.pdf
ABCs of Bookkeeping for Nonprofits TechSoup.pdf
TechSoup
Plate Tectonic Boundaries and Continental Drift Theory
Plate Tectonic Boundaries and Continental Drift Theory
Marie
Wax Moon, Richmond, VA. Terrence McPherson
Wax Moon, Richmond, VA. Terrence McPherson
TerrenceMcPherson1
Non-Communicable Diseases and National Health Programs Unit 10 | B.Sc Nursi...
Non-Communicable Diseases and National Health Programs Unit 10 | B.Sc Nursi...
RAKESH SAJJAN
GEOGRAPHY-Study Material [ Class 10th] .pdf
GEOGRAPHY-Study Material [ Class 10th] .pdf
SHERAZ AHMAD LONE
Paper 109 | Archetypal Journeys in Interstellar: Exploring Universal Themes...
Paper 109 | Archetypal Journeys in Interstellar: Exploring Universal Themes...
Rajdeep Bavaliya
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Pragya - UEM Kolkata Quiz Club
How to Manage Multi Language for Invoice in Odoo 18
How to Manage Multi Language for Invoice in Odoo 18
Celine George
FIRST DAY HIGH orientation for mapeh subject in grade 10.pptx
FIRST DAY HIGH orientation for mapeh subject in grade 10.pptx
GlysdiEelesor1
How to Manage Inventory Movement in Odoo 18 POS
How to Manage Inventory Movement in Odoo 18 POS
Celine George
Ad

Basic Queue Operation in DataStructure.pptx

  • 1. QUEUE IN DATASTRUCTURE (BASIC OPERATION) BY, LAKSHMI, ASSISTANT PROFESSOR, DEPARTMENT OF COMPUTER SCIENCE, SRI ADI CHUNCHANAGIRI WOMENS 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.
  • 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.