SlideShare a Scribd company logo
2
Most read
4
Most read
11
Most read
Sourav Mishra
1801353
1
QUEUE
• Queue is the linear data structure type which is
used to organize the data.
• It is used for temporary storage of data values.
• A new element is added at one end called rear
end
• The existing element deleted from the other end
is called front end.
• First-in-First-out property.
2
Type of queue
Simple
Queue
Circular
Queue
Priority
Queue
Dequeue
(Double
ended
Queue)
3
Simple Queue
• Simple queue defines the simple operation of
queue in which insertion occurs at the rear of
the list and deletion occurs at the front of the
list.
4
Circular Queue
• In a circular queue, all nodes are treated as
circular. Last node is connected back to the
first node.
• Circular queue is also called as Ring Buffer.
• It is an abstract data type.
• Circular queue contains a collection of data
which allows insertion of data at the end of the
queue and deletion of data at the beginning of
the queue
5
x
6
Priority Queue
• Priority queue contains
data items which have
some preset priority.
While removing an
element from a priority
queue, the data item with
the highest priority is
removed first.
• In a priority queue,
insertion is performed in
the order of arrival and
deletion is performed
based on the priority.
7
Dequeue
(Double ended Queue)
• In Double Ended Queue, insert and delete
operation can be occur at both ends that is front
and rear of the queue
8
LINEAR
QUEUE
• A linear data structure that
stores data as a sequence of
element similar to a real
world queue.
• Possible to enter new items
from the rear end and
remove the items from the
front.
• Requires more memory.
• Less efficient.
CIRCULAR
QUEUE
• A linear data structure in
which the last item connects
back to the first item
forming a circle.
• Possible to enter and
remove elements from any
position.
• Requires less memory.
• More efficient.
9
Operations on Queue
• Enqueue() − add (store) an item to the queue.
• Dequeue() − remove (access) an item from the
queue.
• peek() − Gets the element at the front of the
queue without removing it.
• isfull() − Checks if the queue is full.
• isempty() − Checks if the queue is empty
10
Enqueue Operation
• Step 1 − Check if the queue
is full.
• Step 2 − If the queue is full,
produce overflow error and
exit.
• Step 3 − If the queue is not
full, increment rear pointer
to point the next empty
space.
• Step 4 − Add data element
to the queue location, where
the rear is pointing.
• Step 5 − return success.
11
Algorithm Of Enqueue
procedure enqueue(data)
if queue is full
return overflow
12
rear ← rear + 1
queue[rear] ← data
return true
end procedure
int enqueue (int data)
if(isfull())
return 0;
rear = rear + 1;
queue[rear] = data;
return 1;
end procedure
Example of
Enqueue
12
Dequeue Operation
• Step 1 − Check if the queue
is empty.
• Step 2 − If the queue is
empty, produce underflow
error and exit.
• Step 3 − If the queue is not
empty, access the data
where front is pointing.
• Step 4 −
Increment front pointer to
point to the next available
data element.
• Step 5 − Return success.
13
Algorithm for
dequeue operation
procedure dequeue
if queue is empty
return underflow
end if
data = queue[front]
front ← front + 1
return true
end procedure
int dequeue()
{
if(isempty())
return 0;
int data = queue[front]; front =
front + 1;
return data;
}
Example of
Dequeue Operation
14
Application of Queue
• Queue is useful in CPU scheduling, Disk
Scheduling.
• When data is transferred asynchronously
between two processes. Queue is used for
synchronization. Examples : IO Buffers, pipes,
file IO, etc.
• In real life, Call Center phone systems will use
Queues, to hold people calling them in an
order, until a service representative is free.
15
llllllj
16

More Related Content

PPTX
Presentation on queue
PPTX
STACKS IN DATASTRUCTURE
PPTX
stack & queue
PDF
Data structure ppt
PPTX
Tree - Data Structure
PPT
Queue data structure
PPTX
Graph in data structure
PPTX
Linked list
Presentation on queue
STACKS IN DATASTRUCTURE
stack & queue
Data structure ppt
Tree - Data Structure
Queue data structure
Graph in data structure
Linked list

What's hot (20)

PPTX
Queue in Data Structure
PPTX
Data structure - Graph
PPSX
Data Structure (Queue)
PPTX
Linked list
PPTX
Stacks IN DATA STRUCTURES
PPTX
queue & its applications
PPT
PPTX
Binary Search Tree
PPTX
Dynamic memory allocation in c
PPTX
Tree in data structure
PPTX
Array ppt
PPT
1.1 binary tree
PPTX
Doubly Linked List
PPTX
Linear search-and-binary-search
PPTX
Sorting Algorithms
PPTX
linked list in data structure
PDF
Applications of stack
PDF
sparse matrix in data structure
PPTX
Array Introduction One-dimensional array Multidimensional array
PPTX
Breadth First Search & Depth First Search
Queue in Data Structure
Data structure - Graph
Data Structure (Queue)
Linked list
Stacks IN DATA STRUCTURES
queue & its applications
Binary Search Tree
Dynamic memory allocation in c
Tree in data structure
Array ppt
1.1 binary tree
Doubly Linked List
Linear search-and-binary-search
Sorting Algorithms
linked list in data structure
Applications of stack
sparse matrix in data structure
Array Introduction One-dimensional array Multidimensional array
Breadth First Search & Depth First Search
Ad

Similar to Queue ppt (20)

PPTX
queueppt-191018053228 (1).pptx
PPT
Queue AS an ADT (Abstract Data Type)
PPTX
Queue Data Structure
PPTX
DS ppt1.pptx.c programing. Engineering. Data structure
PPTX
@Chapter 4 DSA Part II.pptx
PPTX
Queues
PPT
Chapter 4.pptmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
PPT
queue data structures-linear data structure
PDF
PPTX
Basic Queue Operation in DataStructure.pptx
PPTX
queue.pptx
PPT
Data Structures 2
PPTX
Stack and Queue.pptx
PPTX
DS10-QUEUE0000000000000000000000000000000000000.pptx
PDF
LEC4-DS ALGO.pdf
PPTX
PPTX
Ist year Msc,2nd sem module1
PPT
Stacks and Queues concept in Data Structures
PPTX
Queue Data Structure
queueppt-191018053228 (1).pptx
Queue AS an ADT (Abstract Data Type)
Queue Data Structure
DS ppt1.pptx.c programing. Engineering. Data structure
@Chapter 4 DSA Part II.pptx
Queues
Chapter 4.pptmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
queue data structures-linear data structure
Basic Queue Operation in DataStructure.pptx
queue.pptx
Data Structures 2
Stack and Queue.pptx
DS10-QUEUE0000000000000000000000000000000000000.pptx
LEC4-DS ALGO.pdf
Ist year Msc,2nd sem module1
Stacks and Queues concept in Data Structures
Queue Data Structure
Ad

Recently uploaded (20)

PDF
Structs to JSON How Go Powers REST APIs.pdf
PPTX
Lecture Notes Electrical Wiring System Components
PPTX
CH1 Production IntroductoryConcepts.pptx
PPTX
Construction Project Organization Group 2.pptx
PPTX
Strings in CPP - Strings in C++ are sequences of characters used to store and...
PDF
Well-logging-methods_new................
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PDF
composite construction of structures.pdf
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPTX
Geodesy 1.pptx...............................................
PPTX
web development for engineering and engineering
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PPT
Project quality management in manufacturing
PDF
Digital Logic Computer Design lecture notes
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PPT
Mechanical Engineering MATERIALS Selection
PDF
Arduino robotics embedded978-1-4302-3184-4.pdf
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PPTX
Lesson 3_Tessellation.pptx finite Mathematics
Structs to JSON How Go Powers REST APIs.pdf
Lecture Notes Electrical Wiring System Components
CH1 Production IntroductoryConcepts.pptx
Construction Project Organization Group 2.pptx
Strings in CPP - Strings in C++ are sequences of characters used to store and...
Well-logging-methods_new................
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
composite construction of structures.pdf
Embodied AI: Ushering in the Next Era of Intelligent Systems
Geodesy 1.pptx...............................................
web development for engineering and engineering
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
Project quality management in manufacturing
Digital Logic Computer Design lecture notes
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
Mechanical Engineering MATERIALS Selection
Arduino robotics embedded978-1-4302-3184-4.pdf
UNIT-1 - COAL BASED THERMAL POWER PLANTS
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
Lesson 3_Tessellation.pptx finite Mathematics

Queue ppt

  • 2. QUEUE • Queue is the linear data structure type which is used to organize the data. • It is used for temporary storage of data values. • A new element is added at one end called rear end • The existing element deleted from the other end is called front end. • First-in-First-out property. 2
  • 4. Simple Queue • Simple queue defines the simple operation of queue in which insertion occurs at the rear of the list and deletion occurs at the front of the list. 4
  • 5. Circular Queue • In a circular queue, all nodes are treated as circular. Last node is connected back to the first node. • Circular queue is also called as Ring Buffer. • It is an abstract data type. • Circular queue contains a collection of data which allows insertion of data at the end of the queue and deletion of data at the beginning of the queue 5
  • 6. x 6
  • 7. Priority Queue • Priority queue contains data items which have some preset priority. While removing an element from a priority queue, the data item with the highest priority is removed first. • In a priority queue, insertion is performed in the order of arrival and deletion is performed based on the priority. 7
  • 8. Dequeue (Double ended Queue) • In Double Ended Queue, insert and delete operation can be occur at both ends that is front and rear of the queue 8
  • 9. LINEAR QUEUE • A linear data structure that stores data as a sequence of element similar to a real world queue. • Possible to enter new items from the rear end and remove the items from the front. • Requires more memory. • Less efficient. CIRCULAR QUEUE • A linear data structure in which the last item connects back to the first item forming a circle. • Possible to enter and remove elements from any position. • Requires less memory. • More efficient. 9
  • 10. Operations on Queue • Enqueue() − add (store) an item to the queue. • Dequeue() − remove (access) an item from the queue. • peek() − Gets the element at the front of the queue without removing it. • isfull() − Checks if the queue is full. • isempty() − Checks if the queue is empty 10
  • 11. Enqueue Operation • Step 1 − Check if the queue is full. • Step 2 − If the queue is full, produce overflow error and exit. • Step 3 − If the queue is not full, increment rear pointer to point the next empty space. • Step 4 − Add data element to the queue location, where the rear is pointing. • Step 5 − return success. 11
  • 12. Algorithm Of Enqueue procedure enqueue(data) if queue is full return overflow 12 rear ← rear + 1 queue[rear] ← data return true end procedure int enqueue (int data) if(isfull()) return 0; rear = rear + 1; queue[rear] = data; return 1; end procedure Example of Enqueue 12
  • 13. Dequeue Operation • Step 1 − Check if the queue is empty. • Step 2 − If the queue is empty, produce underflow error and exit. • Step 3 − If the queue is not empty, access the data where front is pointing. • Step 4 − Increment front pointer to point to the next available data element. • Step 5 − Return success. 13
  • 14. Algorithm for dequeue operation procedure dequeue if queue is empty return underflow end if data = queue[front] front ← front + 1 return true end procedure int dequeue() { if(isempty()) return 0; int data = queue[front]; front = front + 1; return data; } Example of Dequeue Operation 14
  • 15. Application of Queue • Queue is useful in CPU scheduling, Disk Scheduling. • When data is transferred asynchronously between two processes. Queue is used for synchronization. Examples : IO Buffers, pipes, file IO, etc. • In real life, Call Center phone systems will use Queues, to hold people calling them in an order, until a service representative is free. 15