SlideShare a Scribd company logo
DATA STRUCTURES
UNIT-2
SELVA KUMAR S
ASSISTANT PROFESSOR
B.M.S. COLLEGE OF ENGINEERING
QUEUE -ADT
• Queue: A list or a collection with the restrictions
that insertion can be performed at one end (the
rear or tail of the queue) and deletion can be
performed at other end (the front or head of the
queue).
• A queue is a FIFO(first in, first out) data structure
– Any waiting line is a queue:
– The check-out line at a grocery store
– The cars at a stop light
– Ticket counter
Conceptual view of a Queue
Uses of Queue in computing
• For any kind of problem involving FIFO Data.
• Printer Queue
• Keyboard Input buffer
• GUI Event Queue
• Web browser request Queue
Uses of Queues in computing
• In simulation studies, where the goal is to
reduce waiting times:
– Optimize the flow of traffic at a traffic light
– Determine the number of cashiers to have on duty
at a grocery store at different times of day
• Process Scheduling
• Printer Queues in Network
Queue Operations
• Enqueue(x) or push(x): add an element to the tail
of a queue.
• Dequeue() or pop(): remove an element from the
head of a queue.
• Front() or peek(): examine the element at the
head of the queue.
• QEmpty() or IsEmpty()
• QFull() or IsFull()
• It is not legal to access the elements in the
middle of the queue!
Implementation of Queues
• Array
• Linked List
Array Implementation
C Code
C code
Circular Queue
• Why we need a circular queue, when we
already have linear queue data structure.
Circular Queue
• Circular Queue is also a linear data structure, which follows
the principle of FIFO(First In First Out), but instead of ending
the queue at the last position, it again starts from the first
position after the last, hence making the queue behave like a
circular data structure.
Circular Queue
• In a circular queue, data is not actually removed from the queue. Only
the head pointer is incremented by one position when dequeue is
executed. As the queue data is only the data between head and tail, hence
the data left outside is not a part of the queue anymore, hence removed.
Circular Queue
• The head and the tail pointer will get reinitialised to 0 every
time they reach the end of the queue.
• Current Position = i
• Next Position = (i+1)% N
• Previous Position = (i+N-1)%N
Application of Circular Queue
• Below we have some common real-world
examples where circular queues are used:
• Computer controlled Traffic Signal
System uses circular queue.
• CPU scheduling and Memory management.
Implementation of Circular Queue
Implementation of Circular Queue
UNIT-2.pptx
C Code – Circular Queue
UNIT-2.pptx
Double ended Queue
• Deque or Double Ended Queue is a type of queue in which insertion
and removal of elements can be performed from either from the
front or rear. Thus, it does not follow FIFO rule (First In First Out).
• Types of Deque
• Input Restricted Deque
– In this deque, input is restricted at a single end but allows deletion at both
the ends.
• Output Restricted Deque
– In this deque, output is restricted at a single end but allows insertion at
both the ends.
Applications
Algorithm
UNIT-2.pptx
C Code
UNIT-2.pptx
UNIT-2.pptx
Priority Queue
• Priority Queue is an extension of queue with
following properties.
– Every item has a priority associated with it.
– An element with high priority is dequeued before
an element with low priority.
– If two elements have the same priority, they are
served according to their order in the queue.
Priority Queue
• In a queue, the first-in-first-out rule is implemented whereas,
in a priority queue, the values are removed on the basis of
priority. The element with the highest priority is removed
first.
Types of Priority Queue
• Min Priority Queue: In min priority Queue
minimum number of value gets the highest
priority and lowest number of element gets
the highest priority.
• Max Priority Queue: Max priority Queue is
the opposite of min priority Queue in it
maximum number value gets the highest
priority and minimum number of value gets
the minimum priority.
Solution
UNIT-2.pptx
UNIT-2.pptx
C Code
C Code
C Code
Priority Queue (Circular Q concept)
UNIT-2.pptx
UNIT-2.pptx

More Related Content

PPTX
DS10-QUEUE0000000000000000000000000000000000000.pptx
PPT
Data Structures 2
PPTX
Unit ii linear data structures
PPTX
STACK AND QUEUES APPLICATIONS, INFIX TO POST FIX
PPT
The Queue in Data structure and algorithm
PPTX
PYTHON PYTHON PYTHON PYTHON PYTHON PYTHON
PPTX
Queue types of queue and algorithms and queue
DS10-QUEUE0000000000000000000000000000000000000.pptx
Data Structures 2
Unit ii linear data structures
STACK AND QUEUES APPLICATIONS, INFIX TO POST FIX
The Queue in Data structure and algorithm
PYTHON PYTHON PYTHON PYTHON PYTHON PYTHON
Queue types of queue and algorithms and queue

Similar to UNIT-2.pptx (20)

PPT
Chapter 4.pptmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
PPTX
queue.pptx
PPT
queue data structures-linear data structure
PDF
Queue ADT for data structure for computer
PPT
This PPT offers insights into data structures in Python, including linked lis...
PDF
Lesson 4 - Queue ADT.pdf
PPTX
Queue_Types_and_Applications9568665.pptx
PPTX
Queues
PPTX
Fundamentals of Data Structure and Queues
PPTX
QUEUE
PPTX
stack.pptx
PPTX
DS ppt1.pptx.c programing. Engineering. Data structure
PPTX
data structures power point presentation
PPT
Data Structures
PDF
Lab 07 (2).pdfbdvdyve dhdysbsnjsnsvdvydbdns
PPTX
GROUP2.pptxfdfffffffffffffffffffffffffffffffffffffffffff
PPTX
Priority_Queue_Presentation_DATA_STRUCTURE_ALGORITHMS.pptx
PPTX
Stack and Queue.pptx
PPT
Fallsem2015 16 cp1699-20-jul-2015_rm01_stacks_and_queues
Chapter 4.pptmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
queue.pptx
queue data structures-linear data structure
Queue ADT for data structure for computer
This PPT offers insights into data structures in Python, including linked lis...
Lesson 4 - Queue ADT.pdf
Queue_Types_and_Applications9568665.pptx
Queues
Fundamentals of Data Structure and Queues
QUEUE
stack.pptx
DS ppt1.pptx.c programing. Engineering. Data structure
data structures power point presentation
Data Structures
Lab 07 (2).pdfbdvdyve dhdysbsnjsnsvdvydbdns
GROUP2.pptxfdfffffffffffffffffffffffffffffffffffffffffff
Priority_Queue_Presentation_DATA_STRUCTURE_ALGORITHMS.pptx
Stack and Queue.pptx
Fallsem2015 16 cp1699-20-jul-2015_rm01_stacks_and_queues
Ad

More from ChiragSuresh (12)

PPTX
GAT Engineering if the computer Dept_.pptx
PPTX
Analyst Trainee Requirement - DWAO - Analytics.pptx
PPT
Unit-1 OOMD- Inthhro- class modeling.ppt
PPTX
wepik-mastering-the-art-of-entrepreneurship-20240313164953QR4t.pptx
PPT
PorterchitwetyujbzxcbbnmlkhggfdPorter.ppt
PPTX
Unit-4- Process oveunit5and6forview.pptx
PPT
osama-quantum-computingoftge quantum.ppt
PPT
Luo_SC_mc_butorqwertyuiomabsvsbsbsjC.ppt
PPTX
Bharti Airtel_ Connectivity Empowering Millions.pptx
PPTX
509404501-Online-Shopping-System-Mini-Project-Ppt (1).pptx
PPTX
Student repository System.pptx
PPT
Unit1_Part2-Machine_Instructions_Programs_7_9_2018_3pm.ppt
GAT Engineering if the computer Dept_.pptx
Analyst Trainee Requirement - DWAO - Analytics.pptx
Unit-1 OOMD- Inthhro- class modeling.ppt
wepik-mastering-the-art-of-entrepreneurship-20240313164953QR4t.pptx
PorterchitwetyujbzxcbbnmlkhggfdPorter.ppt
Unit-4- Process oveunit5and6forview.pptx
osama-quantum-computingoftge quantum.ppt
Luo_SC_mc_butorqwertyuiomabsvsbsbsjC.ppt
Bharti Airtel_ Connectivity Empowering Millions.pptx
509404501-Online-Shopping-System-Mini-Project-Ppt (1).pptx
Student repository System.pptx
Unit1_Part2-Machine_Instructions_Programs_7_9_2018_3pm.ppt
Ad

Recently uploaded (20)

PPTX
Module 8- Technological and Communication Skills.pptx
PDF
SMART SIGNAL TIMING FOR URBAN INTERSECTIONS USING REAL-TIME VEHICLE DETECTI...
PDF
Soil Improvement Techniques Note - Rabbi
PPTX
6ME3A-Unit-II-Sensors and Actuators_Handouts.pptx
PPTX
Artificial Intelligence
PDF
Visual Aids for Exploratory Data Analysis.pdf
PPTX
Feature types and data preprocessing steps
PPTX
communication and presentation skills 01
PDF
EXPLORING LEARNING ENGAGEMENT FACTORS INFLUENCING BEHAVIORAL, COGNITIVE, AND ...
PDF
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
PPTX
Nature of X-rays, X- Ray Equipment, Fluoroscopy
PPTX
Sorting and Hashing in Data Structures with Algorithms, Techniques, Implement...
PDF
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
PPTX
AUTOMOTIVE ENGINE MANAGEMENT (MECHATRONICS).pptx
PPTX
Fundamentals of safety and accident prevention -final (1).pptx
PPTX
Information Storage and Retrieval Techniques Unit III
PDF
August 2025 - Top 10 Read Articles in Network Security & Its Applications
PPTX
introduction to high performance computing
PDF
Human-AI Collaboration: Balancing Agentic AI and Autonomy in Hybrid Systems
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
Module 8- Technological and Communication Skills.pptx
SMART SIGNAL TIMING FOR URBAN INTERSECTIONS USING REAL-TIME VEHICLE DETECTI...
Soil Improvement Techniques Note - Rabbi
6ME3A-Unit-II-Sensors and Actuators_Handouts.pptx
Artificial Intelligence
Visual Aids for Exploratory Data Analysis.pdf
Feature types and data preprocessing steps
communication and presentation skills 01
EXPLORING LEARNING ENGAGEMENT FACTORS INFLUENCING BEHAVIORAL, COGNITIVE, AND ...
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
Nature of X-rays, X- Ray Equipment, Fluoroscopy
Sorting and Hashing in Data Structures with Algorithms, Techniques, Implement...
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
AUTOMOTIVE ENGINE MANAGEMENT (MECHATRONICS).pptx
Fundamentals of safety and accident prevention -final (1).pptx
Information Storage and Retrieval Techniques Unit III
August 2025 - Top 10 Read Articles in Network Security & Its Applications
introduction to high performance computing
Human-AI Collaboration: Balancing Agentic AI and Autonomy in Hybrid Systems
Automation-in-Manufacturing-Chapter-Introduction.pdf

UNIT-2.pptx

  • 1. DATA STRUCTURES UNIT-2 SELVA KUMAR S ASSISTANT PROFESSOR B.M.S. COLLEGE OF ENGINEERING
  • 2. QUEUE -ADT • Queue: A list or a collection with the restrictions that insertion can be performed at one end (the rear or tail of the queue) and deletion can be performed at other end (the front or head of the queue). • A queue is a FIFO(first in, first out) data structure – Any waiting line is a queue: – The check-out line at a grocery store – The cars at a stop light – Ticket counter
  • 4. Uses of Queue in computing • For any kind of problem involving FIFO Data. • Printer Queue • Keyboard Input buffer • GUI Event Queue • Web browser request Queue
  • 5. Uses of Queues in computing • In simulation studies, where the goal is to reduce waiting times: – Optimize the flow of traffic at a traffic light – Determine the number of cashiers to have on duty at a grocery store at different times of day • Process Scheduling • Printer Queues in Network
  • 6. Queue Operations • Enqueue(x) or push(x): add an element to the tail of a queue. • Dequeue() or pop(): remove an element from the head of a queue. • Front() or peek(): examine the element at the head of the queue. • QEmpty() or IsEmpty() • QFull() or IsFull() • It is not legal to access the elements in the middle of the queue!
  • 7. Implementation of Queues • Array • Linked List
  • 11. Circular Queue • Why we need a circular queue, when we already have linear queue data structure.
  • 12. Circular Queue • Circular Queue is also a linear data structure, which follows the principle of FIFO(First In First Out), but instead of ending the queue at the last position, it again starts from the first position after the last, hence making the queue behave like a circular data structure.
  • 13. Circular Queue • In a circular queue, data is not actually removed from the queue. Only the head pointer is incremented by one position when dequeue is executed. As the queue data is only the data between head and tail, hence the data left outside is not a part of the queue anymore, hence removed.
  • 14. Circular Queue • The head and the tail pointer will get reinitialised to 0 every time they reach the end of the queue. • Current Position = i • Next Position = (i+1)% N • Previous Position = (i+N-1)%N
  • 15. Application of Circular Queue • Below we have some common real-world examples where circular queues are used: • Computer controlled Traffic Signal System uses circular queue. • CPU scheduling and Memory management.
  • 19. C Code – Circular Queue
  • 21. Double ended Queue • Deque or Double Ended Queue is a type of queue in which insertion and removal of elements can be performed from either from the front or rear. Thus, it does not follow FIFO rule (First In First Out). • Types of Deque • Input Restricted Deque – In this deque, input is restricted at a single end but allows deletion at both the ends. • Output Restricted Deque – In this deque, output is restricted at a single end but allows insertion at both the ends.
  • 28. Priority Queue • Priority Queue is an extension of queue with following properties. – Every item has a priority associated with it. – An element with high priority is dequeued before an element with low priority. – If two elements have the same priority, they are served according to their order in the queue.
  • 29. Priority Queue • In a queue, the first-in-first-out rule is implemented whereas, in a priority queue, the values are removed on the basis of priority. The element with the highest priority is removed first.
  • 30. Types of Priority Queue • Min Priority Queue: In min priority Queue minimum number of value gets the highest priority and lowest number of element gets the highest priority. • Max Priority Queue: Max priority Queue is the opposite of min priority Queue in it maximum number value gets the highest priority and minimum number of value gets the minimum priority.

Editor's Notes

  • #12: In a Linear queue, once the queue is completely full, it's not possible to insert more elements. Even if we dequeue the queue to remove some of the elements, until the queue is reset, no new elements can be inserted. You must be wondering why?
  • #23: Undo-redo in software application Multi processor scheduling