SlideShare a Scribd company logo
1 of 16
QUEUE
IN
DATA
STRUCTURE
PRESENTED BY-
MEHEDI HASAN
BATCH-D-74
INDEX
I. Introduction
II. Different types of Queue
III. Applications
IV. Conclusion
 Algorithms
 Working procedure
 Calculating Complexity
 Advantage & Disadvantage
INDTODUCTION
Queue is linear data structure. It is a way of storing and
organizing data.
It follows the principle of “first in first out”
Queue Different types of Queue
Operations
Enqueue(): used to inert elements to the end of the Queue
Dequeue(): Remove elements from the frontal side
Isempty() : To check the Queue is empty or not
Peek() : Returns the element of the first at
the queue
Linear Queue Algorithms
Dequeue ():
• Check if the queue is empty
(front == rear == -1).
• If empty, display an underflow error.
• Otherwise, increment front by 1.
• Remove the element from the front position in
the array.
Complexity:
The time complexity of insertion, deletion and
peek operation is O(1). If resizing is necessary
(i.e., when the array is full), then the enqueue
operation may take O(n) time in the worst
case, where n is the current size of the queue.
In Linear Queue, an insertion
takes place from one end while
the deletion occurs from another end.
Algorithms of Linear Queue:
Set array – arr[i]
Set front and rear to -1 to signify an empty queue.
Enqueue ():
• Check if queue is full (rear == SIZE - 1).
• If full, display an overflow error.
• Otherwise, increment tail/rear by 1.
• Insert the element at rear position in the array.
Linear Queue Working procedure
Linear Queue Advantage and Disadvantage
SL
No.
Advantage Disadvantage
1 Simple Implementation Fixed Capacity in Array-based
Implementation
2 Efficient for FIFO Operations Memory Fragmentation in Array-based
Implementation
3 Constant Time Complexity for Basic
Operations
Inefficient Removal of Arbitrary
Elements/Limitation of implementation
4 Suitable for Applications with Limited
Memory
Not Suitable for Priority-based Operations
Priority Queue Algorithms
Dequeue ():
• Remove the element with the highest priority.
• Rearrange the array to fill the gap left by the
removed element.
Complexity:
The time complexity of insertion, deletion is
O(log n).
In Priority Queue elements are arranges based
on their priority (values). Priority queues can be
implemented using Linked List, Heap, Binary search
tree and Array based.
Algorithms of Array-based priority Queue:
Set array – arr[i]
Set front and rear to -1 to signify an empty queue.
Enqueue ():
• Add the element at the end of the array.
• If necessary, reorder the array to maintain the priority
order.
• This can be achieved by comparing the priority of the
newly added element with its parent and swapping if
necessary until the priority order is restored.
Priority Queue working procedure
Dequeue()
Enqueue()
7
6
D Queue Algorithms
Algorithm Pop_Back(deque):
1. If deque is empty, return an error.
2. Get the element from the tail node of the
deque.
3. If deque has only one node:
- Set both head and tail pointers to null.
4. Else:
- Set the previous node of the current tail as
the new tail.
- Set the next pointer of the new tail to null.
5. Decrement the size of the deque.
6. Return the element.
assume a deque implemented using
a doubly linked list
Algorithms of D-Queue:
Algorithm Push_Front(deque, element):
1. Create a new node with the given element.
2. If deque is empty:
- Set the new node as both the head and tail of the
deque.
3. Else:
- Set the previous pointer of the current head node
to point to the new node.
- Set the next pointer of the new node to point to the
current head node.
- Update the head of the deque to point to the new
node.
4. Increment the size of the deque.
D Queue Algorithms
Algorithm Pop_Front(deque):
1. If deque is empty, return an error.
2. Get the element from the head node of the
deque.
3. If deque has only one node:
- Set both head and tail pointers to null.
4. Else:
- Set the next node of the current head as the
new head.
- Set the previous pointer of the new head to
null.
5. Decrement the size of the deque.
6. Return the element.
assume a deque implemented using
a doubly linked list
Algorithms of D-Queue:
Algorithm Push_Back(deque, element):
1. Create a new node with the given element.
2. If deque is empty:
- Set the new node as both the head and tail of the
deque.
3. Else:
- Set the next pointer of the current tail node to
point to the new node.
- Set the previous pointer of the new node to point
to the current tail node.
- Update the tail of the deque to point to the
new node.
4. Increment the size of the deque.
D Queue Working procedure
Queue Applications of Queue
Operating Systems:
Task scheduling: Queues are used in operating systems to manage tasks and processes.
Print spooling: Print jobs are placed in a queue and processed in the order they are received.
Networking:
Network packet handling: Queues are used in network routers and switches to manage incoming and outgoing packets.
Data Structures:
Breadth-first search (BFS): Queues are used in graph traversal algorithms like BFS to explore nodes level by level.
Cache replacement policies: Queues are used in cache implementations to implement replacement policies like FIFO (First-
In-First-Out).
Web Servers:
Request handling: Queues are used in web servers to manage incoming HTTP requests.
Hardware Design:
CPU scheduling: Queues are used in computer architecture and CPU scheduling algorithms to manage the execution of
processes on a multi-core processor.
Queue Conclusion
There can be a lot of memory wastage in static queues, as no matter what is the size of the queue, the space
occupied by it remains the same.
Traversing a queue will delete the foremost element on each iteration, eventually, emptying the queue.
QUEUE in data-structure (classification, working procedure, Applications)

More Related Content

Similar to QUEUE in data-structure (classification, working procedure, Applications)

Queue ADT for data structure for computer
Queue ADT for data structure for computerQueue ADT for data structure for computer
Queue ADT for data structure for computer
abinathsabi
 
Data Structures in C
Data Structures in CData Structures in C
Data Structures in C
Jabs6
 

Similar to QUEUE in data-structure (classification, working procedure, Applications) (20)

queue.pptx
queue.pptxqueue.pptx
queue.pptx
 
Introduction data structure
Introduction data structureIntroduction data structure
Introduction data structure
 
STACK.pptx
STACK.pptxSTACK.pptx
STACK.pptx
 
DS UNIT2QUEUES.pptx
DS UNIT2QUEUES.pptxDS UNIT2QUEUES.pptx
DS UNIT2QUEUES.pptx
 
Queue
QueueQueue
Queue
 
Queue ADT for data structure for computer
Queue ADT for data structure for computerQueue ADT for data structure for computer
Queue ADT for data structure for computer
 
Unit ii linear data structures
Unit ii linear data structures Unit ii linear data structures
Unit ii linear data structures
 
Queues
Queues Queues
Queues
 
PriorityqDhruvBaswal.pptx
PriorityqDhruvBaswal.pptxPriorityqDhruvBaswal.pptx
PriorityqDhruvBaswal.pptx
 
Data Structures
Data StructuresData Structures
Data Structures
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data Structure
 
stack.pptx
stack.pptxstack.pptx
stack.pptx
 
Data Structures in C
Data Structures in CData Structures in C
Data Structures in C
 
Unit i(dsc++)
Unit i(dsc++)Unit i(dsc++)
Unit i(dsc++)
 
Unit 3 Stacks and Queues.pptx
Unit 3 Stacks and Queues.pptxUnit 3 Stacks and Queues.pptx
Unit 3 Stacks and Queues.pptx
 
Unit 1_Stack and Queue using Linked Organization.pdf
Unit 1_Stack and Queue using Linked Organization.pdfUnit 1_Stack and Queue using Linked Organization.pdf
Unit 1_Stack and Queue using Linked Organization.pdf
 
Data structure.ppt
Data structure.pptData structure.ppt
Data structure.ppt
 
Lesson 4 - Queue ADT.pdf
Lesson 4 - Queue ADT.pdfLesson 4 - Queue ADT.pdf
Lesson 4 - Queue ADT.pdf
 
Data structures
Data structuresData structures
Data structures
 
Unit 5 dsa QUEUE
Unit 5 dsa QUEUEUnit 5 dsa QUEUE
Unit 5 dsa QUEUE
 

Recently uploaded

SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
CaitlinCummins3
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
中 央社
 

Recently uploaded (20)

When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
 
8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management
 
demyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptxdemyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptx
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
 
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxAnalyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
 
Scopus Indexed Journals 2024 - ISCOPUS Publications
Scopus Indexed Journals 2024 - ISCOPUS PublicationsScopus Indexed Journals 2024 - ISCOPUS Publications
Scopus Indexed Journals 2024 - ISCOPUS Publications
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
 
PSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptxPSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptx
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptx
 
Supporting Newcomer Multilingual Learners
Supporting Newcomer  Multilingual LearnersSupporting Newcomer  Multilingual Learners
Supporting Newcomer Multilingual Learners
 
An Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppAn Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge App
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
Including Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdfIncluding Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdf
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 

QUEUE in data-structure (classification, working procedure, Applications)

  • 2. INDEX I. Introduction II. Different types of Queue III. Applications IV. Conclusion  Algorithms  Working procedure  Calculating Complexity  Advantage & Disadvantage
  • 3. INDTODUCTION Queue is linear data structure. It is a way of storing and organizing data. It follows the principle of “first in first out”
  • 5. Operations Enqueue(): used to inert elements to the end of the Queue Dequeue(): Remove elements from the frontal side Isempty() : To check the Queue is empty or not Peek() : Returns the element of the first at the queue
  • 6. Linear Queue Algorithms Dequeue (): • Check if the queue is empty (front == rear == -1). • If empty, display an underflow error. • Otherwise, increment front by 1. • Remove the element from the front position in the array. Complexity: The time complexity of insertion, deletion and peek operation is O(1). If resizing is necessary (i.e., when the array is full), then the enqueue operation may take O(n) time in the worst case, where n is the current size of the queue. In Linear Queue, an insertion takes place from one end while the deletion occurs from another end. Algorithms of Linear Queue: Set array – arr[i] Set front and rear to -1 to signify an empty queue. Enqueue (): • Check if queue is full (rear == SIZE - 1). • If full, display an overflow error. • Otherwise, increment tail/rear by 1. • Insert the element at rear position in the array.
  • 8. Linear Queue Advantage and Disadvantage SL No. Advantage Disadvantage 1 Simple Implementation Fixed Capacity in Array-based Implementation 2 Efficient for FIFO Operations Memory Fragmentation in Array-based Implementation 3 Constant Time Complexity for Basic Operations Inefficient Removal of Arbitrary Elements/Limitation of implementation 4 Suitable for Applications with Limited Memory Not Suitable for Priority-based Operations
  • 9. Priority Queue Algorithms Dequeue (): • Remove the element with the highest priority. • Rearrange the array to fill the gap left by the removed element. Complexity: The time complexity of insertion, deletion is O(log n). In Priority Queue elements are arranges based on their priority (values). Priority queues can be implemented using Linked List, Heap, Binary search tree and Array based. Algorithms of Array-based priority Queue: Set array – arr[i] Set front and rear to -1 to signify an empty queue. Enqueue (): • Add the element at the end of the array. • If necessary, reorder the array to maintain the priority order. • This can be achieved by comparing the priority of the newly added element with its parent and swapping if necessary until the priority order is restored.
  • 10. Priority Queue working procedure Dequeue() Enqueue() 7 6
  • 11. D Queue Algorithms Algorithm Pop_Back(deque): 1. If deque is empty, return an error. 2. Get the element from the tail node of the deque. 3. If deque has only one node: - Set both head and tail pointers to null. 4. Else: - Set the previous node of the current tail as the new tail. - Set the next pointer of the new tail to null. 5. Decrement the size of the deque. 6. Return the element. assume a deque implemented using a doubly linked list Algorithms of D-Queue: Algorithm Push_Front(deque, element): 1. Create a new node with the given element. 2. If deque is empty: - Set the new node as both the head and tail of the deque. 3. Else: - Set the previous pointer of the current head node to point to the new node. - Set the next pointer of the new node to point to the current head node. - Update the head of the deque to point to the new node. 4. Increment the size of the deque.
  • 12. D Queue Algorithms Algorithm Pop_Front(deque): 1. If deque is empty, return an error. 2. Get the element from the head node of the deque. 3. If deque has only one node: - Set both head and tail pointers to null. 4. Else: - Set the next node of the current head as the new head. - Set the previous pointer of the new head to null. 5. Decrement the size of the deque. 6. Return the element. assume a deque implemented using a doubly linked list Algorithms of D-Queue: Algorithm Push_Back(deque, element): 1. Create a new node with the given element. 2. If deque is empty: - Set the new node as both the head and tail of the deque. 3. Else: - Set the next pointer of the current tail node to point to the new node. - Set the previous pointer of the new node to point to the current tail node. - Update the tail of the deque to point to the new node. 4. Increment the size of the deque.
  • 13. D Queue Working procedure
  • 14. Queue Applications of Queue Operating Systems: Task scheduling: Queues are used in operating systems to manage tasks and processes. Print spooling: Print jobs are placed in a queue and processed in the order they are received. Networking: Network packet handling: Queues are used in network routers and switches to manage incoming and outgoing packets. Data Structures: Breadth-first search (BFS): Queues are used in graph traversal algorithms like BFS to explore nodes level by level. Cache replacement policies: Queues are used in cache implementations to implement replacement policies like FIFO (First- In-First-Out). Web Servers: Request handling: Queues are used in web servers to manage incoming HTTP requests. Hardware Design: CPU scheduling: Queues are used in computer architecture and CPU scheduling algorithms to manage the execution of processes on a multi-core processor.
  • 15. Queue Conclusion There can be a lot of memory wastage in static queues, as no matter what is the size of the queue, the space occupied by it remains the same. Traversing a queue will delete the foremost element on each iteration, eventually, emptying the queue.