SlideShare a Scribd company logo
2
Most read
3
Most read
5
Most read
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) (20)

PPT
Lec-07 Queues.ppt queues introduction to queue
AmsaAzeem
 
PPTX
Queue and its operations
V.V.Vanniaperumal College for Women
 
PPTX
queue & its applications
somendra kumar
 
PPTX
queue_final.pptx
MeghaKulkarni27
 
PPTX
The presention is about the queue data structure
gaurav77712
 
PPTX
@Chapter 4 DSA Part II.pptx
NuraMohamed9
 
PPTX
apllicationsof queffffffffffffffffffffffffffffue.pptx
shesnasuneer
 
PPTX
VCE Unit 03vv.pptx
skilljiolms
 
PDF
Basic Terminologies of Queue...Basic operations on Queue
arpitasen55
 
PPT
Lecture three of datat structures ,.The Queue-ds.ppt
donemoremaregere376
 
PPTX
Queue
Ayaz Akhtar
 
PPTX
Queue data structures and operation on data structures
muskans14
 
PPTX
Bsc cs ii dfs u-2 linklist,stack,queue
Rai University
 
PPTX
Mca ii dfs u-3 linklist,stack,queue
Rai University
 
PPTX
DS10-QUEUE0000000000000000000000000000000000000.pptx
ProfVMGawde
 
PPT
Lecture 2d queues
Victor Palmar
 
PPT
Queue Data Structure
Lovely Professional University
 
PPT
QUEUE IN DATA STRUCTURE USING C
Meghaj Mallick
 
PPT
The Queue in Data structure and algorithm
SourajitMaity1
 
Lec-07 Queues.ppt queues introduction to queue
AmsaAzeem
 
Queue and its operations
V.V.Vanniaperumal College for Women
 
queue & its applications
somendra kumar
 
queue_final.pptx
MeghaKulkarni27
 
The presention is about the queue data structure
gaurav77712
 
@Chapter 4 DSA Part II.pptx
NuraMohamed9
 
apllicationsof queffffffffffffffffffffffffffffue.pptx
shesnasuneer
 
VCE Unit 03vv.pptx
skilljiolms
 
Basic Terminologies of Queue...Basic operations on Queue
arpitasen55
 
Lecture three of datat structures ,.The Queue-ds.ppt
donemoremaregere376
 
Queue data structures and operation on data structures
muskans14
 
Bsc cs ii dfs u-2 linklist,stack,queue
Rai University
 
Mca ii dfs u-3 linklist,stack,queue
Rai University
 
DS10-QUEUE0000000000000000000000000000000000000.pptx
ProfVMGawde
 
Lecture 2d queues
Victor Palmar
 
Queue Data Structure
Lovely Professional University
 
QUEUE IN DATA STRUCTURE USING C
Meghaj Mallick
 
The Queue in Data structure and algorithm
SourajitMaity1
 

Recently uploaded (20)

PPTX
How to Manage Access Rights & User Types in Odoo 18
Celine George
 
PPTX
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
PDF
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
PPTX
How to Manage Promotions in Odoo 18 Sales
Celine George
 
PPTX
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
PDF
Zoology (Animal Physiology) practical Manual
raviralanaresh2
 
PPTX
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
PDF
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
PPSX
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
PDF
IMP NAAC REFORMS 2024 - 10 Attributes.pdf
BHARTIWADEKAR
 
PPTX
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
PPTX
Latest Features in Odoo 18 - Odoo slides
Celine George
 
PPTX
Views on Education of Indian Thinkers Mahatma Gandhi.pptx
ShrutiMahanta1
 
PDF
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
PDF
Federal dollars withheld by district, charter, grant recipient
Mebane Rash
 
PPTX
Nutri-QUIZ-Bee-Elementary.pptx...................
ferdinandsanbuenaven
 
PPTX
How to Define Translation to Custom Module And Add a new language in Odoo 18
Celine George
 
PDF
The-Beginnings-of-Indian-Civilisation.pdf/6th class new ncert social/by k san...
Sandeep Swamy
 
PDF
CEREBRAL PALSY: NURSING MANAGEMENT .pdf
PRADEEP ABOTHU
 
PPTX
HEAD INJURY IN CHILDREN: NURSING MANAGEMENGT.pptx
PRADEEP ABOTHU
 
How to Manage Access Rights & User Types in Odoo 18
Celine George
 
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
How to Manage Promotions in Odoo 18 Sales
Celine George
 
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
Zoology (Animal Physiology) practical Manual
raviralanaresh2
 
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
IMP NAAC REFORMS 2024 - 10 Attributes.pdf
BHARTIWADEKAR
 
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
Latest Features in Odoo 18 - Odoo slides
Celine George
 
Views on Education of Indian Thinkers Mahatma Gandhi.pptx
ShrutiMahanta1
 
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
Federal dollars withheld by district, charter, grant recipient
Mebane Rash
 
Nutri-QUIZ-Bee-Elementary.pptx...................
ferdinandsanbuenaven
 
How to Define Translation to Custom Module And Add a new language in Odoo 18
Celine George
 
The-Beginnings-of-Indian-Civilisation.pdf/6th class new ncert social/by k san...
Sandeep Swamy
 
CEREBRAL PALSY: NURSING MANAGEMENT .pdf
PRADEEP ABOTHU
 
HEAD INJURY IN CHILDREN: NURSING MANAGEMENGT.pptx
PRADEEP ABOTHU
 
Ad

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.