SlideShare a Scribd company logo
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.
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

More Related Content

PPTX
DataSructure-Time and Space Complexity.pptx
PPTX
Queue and its operations
PPT
Disk scheduling algorithms
PDF
COMPUTER ORGANIZATION NOTES Unit 2
PPTX
Nested queries in database
PPT
OPERATING SYSTEM SERVICES, OPERATING SYSTEM STRUCTURES
PDF
Distributed process and scheduling
PPTX
SCHEDULING ALGORITHMS
DataSructure-Time and Space Complexity.pptx
Queue and its operations
Disk scheduling algorithms
COMPUTER ORGANIZATION NOTES Unit 2
Nested queries in database
OPERATING SYSTEM SERVICES, OPERATING SYSTEM STRUCTURES
Distributed process and scheduling
SCHEDULING ALGORITHMS

What's hot (20)

PPTX
Conceptual design & ER Model.pptx
PPTX
Addressing modes
PPTX
Process in operating system
PPTX
Lecture 6- Deadlocks.pptx
PPTX
Selection Statements in C Programming
PDF
COMPUTER ORGANIZATION NOTES Unit 7
PPTX
07. Virtual Functions
PDF
Introduction to Bus | Address, Data, Control Bus
PDF
Linked list implementation of Queue
PPT
PPT
cpp input & output system basics
PPT
Stacks, Queues, Deques
PPTX
Stacks IN DATA STRUCTURES
PPTX
concept of Array, 1D & 2D array
PPTX
Templates in c++
PPTX
Asynchronous Data Transfer.pptx
PPTX
Data structure and its types
PPTX
Microprocessor
PPTX
MULTILEVEL QUEUE SCHEDULING
PPTX
Swapping | Computer Science
Conceptual design & ER Model.pptx
Addressing modes
Process in operating system
Lecture 6- Deadlocks.pptx
Selection Statements in C Programming
COMPUTER ORGANIZATION NOTES Unit 7
07. Virtual Functions
Introduction to Bus | Address, Data, Control Bus
Linked list implementation of Queue
cpp input & output system basics
Stacks, Queues, Deques
Stacks IN DATA STRUCTURES
concept of Array, 1D & 2D array
Templates in c++
Asynchronous Data Transfer.pptx
Data structure and its types
Microprocessor
MULTILEVEL QUEUE SCHEDULING
Swapping | Computer Science
Ad

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

PDF
Lab 07 (2).pdfbdvdyve dhdysbsnjsnsvdvydbdns
PDF
Algorithm and Data Structure - Queue
PDF
PPTX
Queue Data Structure
PPTX
queueppt-191018053228 (1).pptx
PPTX
Stack and queue
PPTX
Unit-ii-Queue ADT.pptx
PPTX
Queue ppt
PPTX
DS10-QUEUE0000000000000000000000000000000000000.pptx
PPT
Queue AS an ADT (Abstract Data Type)
PPTX
Queues
PPT
The Queue in Data structure and algorithm
PDF
5-Queue-----------------------------in c++
PPTX
DS ppt1.pptx.c programing. Engineering. Data structure
PPTX
QUEUE PPT BY KULJIT SINGH.pptx
PDF
4-Stack --------------------------------in C++.pdf
PPTX
CHAPTER 4 Learning QUEUE data structure.pptx
PPTX
Unit 3 Stacks and Queues.pptx
PPTX
@Chapter 4 DSA Part II.pptx
Lab 07 (2).pdfbdvdyve dhdysbsnjsnsvdvydbdns
Algorithm and Data Structure - Queue
Queue Data Structure
queueppt-191018053228 (1).pptx
Stack and queue
Unit-ii-Queue ADT.pptx
Queue ppt
DS10-QUEUE0000000000000000000000000000000000000.pptx
Queue AS an ADT (Abstract Data Type)
Queues
The Queue in Data structure and algorithm
5-Queue-----------------------------in c++
DS ppt1.pptx.c programing. Engineering. Data structure
QUEUE PPT BY KULJIT SINGH.pptx
4-Stack --------------------------------in C++.pdf
CHAPTER 4 Learning QUEUE data structure.pptx
Unit 3 Stacks and Queues.pptx
@Chapter 4 DSA Part II.pptx
Ad

More from LakshmiSamivel (14)

PPT
Greedy Algorithm for Computer Science.ppt
PPTX
General methodin Data Structure for UG.pptx
PPTX
DIVIDE AND CONQUERMETHOD IN DATASTRUCTURE.pptx
PPTX
Presentation DM.pptx
PPTX
Dos.pptx
PPTX
Formatting tags
PPTX
Classification of datastructure.ppt
PPTX
Top down parsing
PPTX
Semaphore
PPTX
Firewall ppt
PPTX
PPT
Procedures andcursors
PDF
Computer network notes
DOCX
OsI reference model
Greedy Algorithm for Computer Science.ppt
General methodin Data Structure for UG.pptx
DIVIDE AND CONQUERMETHOD IN DATASTRUCTURE.pptx
Presentation DM.pptx
Dos.pptx
Formatting tags
Classification of datastructure.ppt
Top down parsing
Semaphore
Firewall ppt
Procedures andcursors
Computer network notes
OsI reference model

Recently uploaded (20)

PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PPTX
Cell Structure & Organelles in detailed.
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
Business Ethics Teaching Materials for college
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Pharma ospi slides which help in ospi learning
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Module 4: Burden of Disease Tutorial Slides S2 2025
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Cell Structure & Organelles in detailed.
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Anesthesia in Laparoscopic Surgery in India
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PPH.pptx obstetrics and gynecology in nursing
STATICS OF THE RIGID BODIES Hibbelers.pdf
Microbial disease of the cardiovascular and lymphatic systems
Business Ethics Teaching Materials for college
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Final Presentation General Medicine 03-08-2024.pptx
Pharma ospi slides which help in ospi learning
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...

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.
  • 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.”