SlideShare a Scribd company logo
2
Most read
4
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

PPTX
DS10-QUEUE0000000000000000000000000000000000000.pptx
PPTX
stacks and queues for public
PPTX
Data Structures_Linear Data Structures Queue.pptx
PPTX
DSA_Ques ewoifhjerofhefhehfreofheek.pptx
PPT
Chapter 7 ds
PPTX
The presention is about the queue data structure
PPT
05-stack_queue.ppt
DS10-QUEUE0000000000000000000000000000000000000.pptx
stacks and queues for public
Data Structures_Linear Data Structures Queue.pptx
DSA_Ques ewoifhjerofhefhehfreofheek.pptx
Chapter 7 ds
The presention is about the queue data structure
05-stack_queue.ppt

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

DOCX
Stacks
PPTX
Ist year Msc,2nd sem module1
PPT
queuesArrays.ppt bbbbbbbbbbbbbbbbbbbbbbbbbb
PPTX
Queue collection of Frame work in oops through java
PDF
COMPUTER LABORATORY-4 LAB MANUAL BE COMPUTER ENGINEERING
PPTX
queue.pptx
PDF
Introduction data structure
PPTX
Queue types of queue and algorithms and queue
PPTX
STACK.pptx
PPTX
DS UNIT2QUEUES.pptx
PPTX
PDF
Queue ADT for data structure for computer
PPT
The Queue in Data structure and algorithm
PPTX
Unit ii linear data structures
PPTX
Queues
PPTX
PriorityqDhruvBaswal.pptx
PPT
Data Structures
PPT
Queue Data Structure
PPTX
stack.pptx
PPTX
Data Structures in C
Stacks
Ist year Msc,2nd sem module1
queuesArrays.ppt bbbbbbbbbbbbbbbbbbbbbbbbbb
Queue collection of Frame work in oops through java
COMPUTER LABORATORY-4 LAB MANUAL BE COMPUTER ENGINEERING
queue.pptx
Introduction data structure
Queue types of queue and algorithms and queue
STACK.pptx
DS UNIT2QUEUES.pptx
Queue ADT for data structure for computer
The Queue in Data structure and algorithm
Unit ii linear data structures
Queues
PriorityqDhruvBaswal.pptx
Data Structures
Queue Data Structure
stack.pptx
Data Structures in C
Ad

Recently uploaded (20)

PPTX
Institutional Correction lecture only . . .
PPTX
Cell Types and Its function , kingdom of life
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 Đ...
PDF
Pre independence Education in Inndia.pdf
PDF
Complications of Minimal Access Surgery at WLH
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
01-Introduction-to-Information-Management.pdf
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PPTX
Pharma ospi slides which help in ospi learning
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
Lesson notes of climatology university.
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
RMMM.pdf make it easy to upload and study
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Institutional Correction lecture only . . .
Cell Types and Its function , kingdom of life
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Pre independence Education in Inndia.pdf
Complications of Minimal Access Surgery at WLH
Supply Chain Operations Speaking Notes -ICLT Program
VCE English Exam - Section C Student Revision Booklet
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
Final Presentation General Medicine 03-08-2024.pptx
01-Introduction-to-Information-Management.pdf
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
STATICS OF THE RIGID BODIES Hibbelers.pdf
Renaissance Architecture: A Journey from Faith to Humanism
Pharma ospi slides which help in ospi learning
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Abdominal Access Techniques with Prof. Dr. R K Mishra
Lesson notes of climatology university.
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
RMMM.pdf make it easy to upload and study
Pharmacology of Heart Failure /Pharmacotherapy of CHF
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.