SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Was ist angesagt?

Laporan Praktikum Bahan Bangunan 1 "Pengujian BERAT JENIS PASIR"
Laporan Praktikum Bahan Bangunan 1 "Pengujian BERAT JENIS PASIR"Laporan Praktikum Bahan Bangunan 1 "Pengujian BERAT JENIS PASIR"
Laporan Praktikum Bahan Bangunan 1 "Pengujian BERAT JENIS PASIR"
bawon15505124020
 
Bab I Rancang Bangun Sistem Informasi Pelayanan Kantor Desa Saketi Berbasis WEB
Bab I Rancang Bangun Sistem Informasi Pelayanan Kantor Desa Saketi Berbasis WEB Bab I Rancang Bangun Sistem Informasi Pelayanan Kantor Desa Saketi Berbasis WEB
Bab I Rancang Bangun Sistem Informasi Pelayanan Kantor Desa Saketi Berbasis WEB
IKHSAN MAHRURI
 
Fundamentals of data structures ellis horowitz & sartaj sahni
Fundamentals of data structures   ellis horowitz & sartaj sahniFundamentals of data structures   ellis horowitz & sartaj sahni
Fundamentals of data structures ellis horowitz & sartaj sahni
Hitesh Wagle
 

Was ist angesagt? (20)

Algoritma Apriori
Algoritma AprioriAlgoritma Apriori
Algoritma Apriori
 
3 konsep dasar sistem informasi
3 konsep dasar sistem informasi3 konsep dasar sistem informasi
3 konsep dasar sistem informasi
 
teori Struktur data full
teori Struktur data fullteori Struktur data full
teori Struktur data full
 
Data structure stack&queue basics
Data structure stack&queue   basicsData structure stack&queue   basics
Data structure stack&queue basics
 
Pertemuan 11-12 Ketidakpastian (Uncertainty)
Pertemuan 11-12 Ketidakpastian (Uncertainty)Pertemuan 11-12 Ketidakpastian (Uncertainty)
Pertemuan 11-12 Ketidakpastian (Uncertainty)
 
5. Doubly Linked List (Struktur Data)
5. Doubly Linked List (Struktur Data)5. Doubly Linked List (Struktur Data)
5. Doubly Linked List (Struktur Data)
 
4.1 Operasi Dasar Singly Linked List 1 (primitive list)
4.1 Operasi Dasar Singly Linked List  1 (primitive list)4.1 Operasi Dasar Singly Linked List  1 (primitive list)
4.1 Operasi Dasar Singly Linked List 1 (primitive list)
 
Queue in Data Structure
Queue in Data StructureQueue in Data Structure
Queue in Data Structure
 
Materi kesekertariatan
Materi kesekertariatanMateri kesekertariatan
Materi kesekertariatan
 
Laporan Praktikum Bahan Bangunan 1 "Pengujian BERAT JENIS PASIR"
Laporan Praktikum Bahan Bangunan 1 "Pengujian BERAT JENIS PASIR"Laporan Praktikum Bahan Bangunan 1 "Pengujian BERAT JENIS PASIR"
Laporan Praktikum Bahan Bangunan 1 "Pengujian BERAT JENIS PASIR"
 
1.4 expression tree
1.4 expression tree  1.4 expression tree
1.4 expression tree
 
Makalah shell sort
Makalah shell sortMakalah shell sort
Makalah shell sort
 
Soal uas struktur data
Soal uas struktur dataSoal uas struktur data
Soal uas struktur data
 
Algoritma brute force
Algoritma brute forceAlgoritma brute force
Algoritma brute force
 
Laporan praktek kerja lapangan
Laporan praktek kerja lapanganLaporan praktek kerja lapangan
Laporan praktek kerja lapangan
 
Stack and queue
Stack and queueStack and queue
Stack and queue
 
Bab I Rancang Bangun Sistem Informasi Pelayanan Kantor Desa Saketi Berbasis WEB
Bab I Rancang Bangun Sistem Informasi Pelayanan Kantor Desa Saketi Berbasis WEB Bab I Rancang Bangun Sistem Informasi Pelayanan Kantor Desa Saketi Berbasis WEB
Bab I Rancang Bangun Sistem Informasi Pelayanan Kantor Desa Saketi Berbasis WEB
 
Tkk
TkkTkk
Tkk
 
Expression trees
Expression treesExpression trees
Expression trees
 
Fundamentals of data structures ellis horowitz & sartaj sahni
Fundamentals of data structures   ellis horowitz & sartaj sahniFundamentals of data structures   ellis horowitz & sartaj sahni
Fundamentals of data structures ellis horowitz & sartaj sahni
 

Ähnlich wie Basic Queue Operation in DataStructure.pptx

queueppt-191018053228 (1).pptx
queueppt-191018053228 (1).pptxqueueppt-191018053228 (1).pptx
queueppt-191018053228 (1).pptx
MeghaKulkarni27
 
Stacks-and-Queues.pdf
Stacks-and-Queues.pdfStacks-and-Queues.pdf
Stacks-and-Queues.pdf
TobyWtf
 

Ähnlich wie 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
 
Unit-ii-Queue ADT.pptx
Unit-ii-Queue ADT.pptxUnit-ii-Queue ADT.pptx
Unit-ii-Queue ADT.pptx
 
Queue ppt
Queue pptQueue ppt
Queue ppt
 
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)
 
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
 
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
 

Mehr von LakshmiSamivel

Mehr von 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
 
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
 
Top down parsing
Top down parsingTop down parsing
Top down parsing
 
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
 

Kürzlich hochgeladen

BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
SoniaTolstoy
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
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
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
fonyou31
 

Kürzlich hochgeladen (20)

BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
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
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
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
 
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
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
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
 
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...
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
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
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 

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