SlideShare a Scribd company logo
1 of 13
1
Presentation on Priority Queue
Presented By:
Md. Noyan Ali
Dept. of CSE, KUET
Presentation Date : May, 2018
Definition : A priority queue is a collection of elements such that each elements has
been assigned a priority and such that the order in which elements are deleted and
processed comes from the following rules :
1. An element of higher priority is processed before any element of lower
priority.
2. Two elements with the same priority are processed according to the
order in which they were added to the queue.
A prototype of a priority queue is a timesharing system : programs of high priority
are processed first and programs with the same priority forma a standard queue.
Implementation : There are two ways of representation of Priority Queue –
1. One-way List Representation of Priority Queue &
2. Array Representation of Priority Queue.
Priority Queue
INFO
B
D
E
A
C
G
F
PRN
2
4
4
1
2
5
4
LINK
6
4
9
1
3
0
8
5
2 1
2
3
4
5
6
7
8
9
10
11
12
AVAIL
START
A 1
G 5 X
F 4
E 4
D 4
C 2
B 2
START
One-Way List Representation of a Priority Queue :
INFO
B
X
D
E
A
C
G
F
PRN
2
2
4
4
1
2
5
4
LINK
6
3
4
9
1
2
0
8
5
7 1
2
3
4
5
6
7
8
9
10
11
12
AVAIL
START
A 1
G 5 X
F 4
E 4
D 4
C 2
B 2
START
One-Way List Representation of a Priority Queue – Insertion :
X 2
Inserting Element X with Priority 2 :
INFO
B
X
D
E
C
G
F
PRN
2
2
4
4
2
5
4
LINK
6
3
4
9
2
0
8
1
5 1
2
3
4
5
6
7
8
9
10
11
12
AVAIL
START
G 5 X
F 4
E 4
D 4
C 2
B 2
START
One-Way List Representation of a Priority Queue – Deletion :
X 2
Deleting an Element :
Algorithm for deletion : This algorithm deletes and processes the first element in a
priority queue which appears in a memory as a one-way list -
1. Set ITEM = INFO[START]. [This saves the data in the first node.]
2. Delete first node from the list.
3. Process ITEM.
4. Exit.
Algorithm for addition: This algorithm adds an ITEM with priority number N to a
priority queue which is maintained in a memory as a one-way list -
1. Traverse the one-way list until finding a node X whose priority number
exceeds N. ITEM in front of node X.
2. If no such node i found, insert ITEM as the last element of the list.
Algorithms for One-Way List of PQ Operations :
FRONT
2
1
0
5
4
REAR
2
2
0
1
4
1
2
3
4
5
1 2 3 4 5 6
1 A
2 B C
3
4 D E
5 G
A 1
G 5
F 4
E 4
D 4
C 2
B 2
START
Array Representation of a Priority Queue :
FRONT
2
1
0
5
4
REAR
2
3
0
1
4
1
2
3
4
5
1 2 3 4 5 6
1 A
2 B C X
3
4 D E
5 G
A 1
G 5
F 4
E 4
D 4
C 2
B 2
START
Array Representation of a Priority Queue – Insertion :
Inserting Element X with Priority 2 :
C 2
FRONT
0
1
0
5
4
REAR
0
3
0
1
4
1
2
3
4
5
1 2 3 4 5 6
1 A
2 B C X
3
4 D E
5 G
G 5 X
F 4
E 4
D 4
C 2
B 2
START
Array Representation of a Priority Queue – Deletion :
Deleting an Element :
C 2
Algorithm for deletion: This algorithm deletes and processes the first element in a
priority queue maintained by a two-dimensional array QUEUE -
1. [Find the first nonempty queue.]
Find the smallest k such that FRONT[k] != NULL.
2. Delete and process the front element in row k of queue.
3. Exit.
Algorithm for addition: This algorithm adds an ITEM with priority number M to a
priority queue maintained by a two-dimensional array QUEUE -
1. Insert ITEM as the rear element in row M of QUEUE.
2. Exit.
Algorithms for Array Representation of PQ Operations :
• Efficiency for array representation : The array representation of a priority queue is
more time efficient than a one-way list. This is because when adding an element
to a one-way list, one must perform a linear search on the list.
• Efficiency for one-way list representation : The one-way list representation of a
priority queue is more space efficient than the array representation. This is
because in using the array representation, overflow occurs when the number of
elements in any single priority level exceeds the capacity for that level, but in
using one-way list representation , overflow occurs only when the total number of
elements exceeds the total capacity.
References :
1. Theory and Problems of DATA STRUCTURE – SEYMOUR LIPSCHUTZ.
2. http://btechsmartclass.com/DS/U3_T6.html. (accessed on 07 May, 2018)
Thanks For Watching!

More Related Content

What's hot

Quick and radix sort
Quick and radix sortQuick and radix sort
Quick and radix sortAaron Joaquin
 
Binary search
Binary search Binary search
Binary search Raghu nath
 
linear search and binary search
linear search and binary searchlinear search and binary search
linear search and binary searchZia Ush Shamszaman
 
9781111530532 ppt ch14_quick_sort
9781111530532 ppt ch14_quick_sort9781111530532 ppt ch14_quick_sort
9781111530532 ppt ch14_quick_sortTerry Yoast
 
Dsa – data structure and algorithms searching
Dsa – data structure and algorithms   searchingDsa – data structure and algorithms   searching
Dsa – data structure and algorithms searchingsajinis3
 
Lect11 Sorting
Lect11 SortingLect11 Sorting
Lect11 Sortingryokollll
 
4 chapter3 list_stackqueuepart1
4 chapter3 list_stackqueuepart14 chapter3 list_stackqueuepart1
4 chapter3 list_stackqueuepart1SSE_AndyLi
 
Dsa – data structure and algorithms sorting
Dsa – data structure and algorithms  sortingDsa – data structure and algorithms  sorting
Dsa – data structure and algorithms sortingsajinis3
 
Algorithm & data structures lec4&5
Algorithm & data structures lec4&5Algorithm & data structures lec4&5
Algorithm & data structures lec4&5Abdul Khan
 
UNIT II LINEAR DATA STRUCTURES – STACKS, QUEUES
UNIT II 	LINEAR DATA STRUCTURES – STACKS, QUEUES	UNIT II 	LINEAR DATA STRUCTURES – STACKS, QUEUES
UNIT II LINEAR DATA STRUCTURES – STACKS, QUEUES Kathirvel Ayyaswamy
 
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHIBCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHISowmya Jyothi
 

What's hot (20)

Data structure
Data structureData structure
Data structure
 
Searching techniques
Searching techniquesSearching techniques
Searching techniques
 
Quick and radix sort
Quick and radix sortQuick and radix sort
Quick and radix sort
 
Binary search
Binary search Binary search
Binary search
 
linear search and binary search
linear search and binary searchlinear search and binary search
linear search and binary search
 
9781111530532 ppt ch14_quick_sort
9781111530532 ppt ch14_quick_sort9781111530532 ppt ch14_quick_sort
9781111530532 ppt ch14_quick_sort
 
02 Stack
02 Stack02 Stack
02 Stack
 
Dsa – data structure and algorithms searching
Dsa – data structure and algorithms   searchingDsa – data structure and algorithms   searching
Dsa – data structure and algorithms searching
 
Sorting
SortingSorting
Sorting
 
Lect11 Sorting
Lect11 SortingLect11 Sorting
Lect11 Sorting
 
4 chapter3 list_stackqueuepart1
4 chapter3 list_stackqueuepart14 chapter3 list_stackqueuepart1
4 chapter3 list_stackqueuepart1
 
Dsa – data structure and algorithms sorting
Dsa – data structure and algorithms  sortingDsa – data structure and algorithms  sorting
Dsa – data structure and algorithms sorting
 
Algorithm & data structures lec4&5
Algorithm & data structures lec4&5Algorithm & data structures lec4&5
Algorithm & data structures lec4&5
 
Sorting
SortingSorting
Sorting
 
201801 CSE240 Lecture 21
201801 CSE240 Lecture 21201801 CSE240 Lecture 21
201801 CSE240 Lecture 21
 
Insertion sort algorithm power point presentation
Insertion  sort algorithm power point presentation Insertion  sort algorithm power point presentation
Insertion sort algorithm power point presentation
 
UNIT II LINEAR DATA STRUCTURES – STACKS, QUEUES
UNIT II 	LINEAR DATA STRUCTURES – STACKS, QUEUES	UNIT II 	LINEAR DATA STRUCTURES – STACKS, QUEUES
UNIT II LINEAR DATA STRUCTURES – STACKS, QUEUES
 
Javascript stack
Javascript   stackJavascript   stack
Javascript stack
 
Quick sorting
Quick sortingQuick sorting
Quick sorting
 
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHIBCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
 

Similar to Priority Queue

Data structure using c module 3
Data structure using c module 3Data structure using c module 3
Data structure using c module 3smruti sarangi
 
Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1blessyboban92
 
DS - Unit 2 FINAL (2).pptx
DS - Unit 2 FINAL (2).pptxDS - Unit 2 FINAL (2).pptx
DS - Unit 2 FINAL (2).pptxprakashvs7
 
Data Structures_ Sorting & Searching
Data Structures_ Sorting & SearchingData Structures_ Sorting & Searching
Data Structures_ Sorting & SearchingThenmozhiK5
 
Chapter 14 quick_sort
Chapter 14 quick_sortChapter 14 quick_sort
Chapter 14 quick_sortTerry Yoast
 
List - Operations and Implementation
List - Operations and ImplementationList - Operations and Implementation
List - Operations and ImplementationSagacious IT Solution
 
Unit III Version I.pptx
Unit III Version I.pptxUnit III Version I.pptx
Unit III Version I.pptxssuserd602fd
 
VCE Unit 03vv.pptx
VCE Unit 03vv.pptxVCE Unit 03vv.pptx
VCE Unit 03vv.pptxskilljiolms
 
queue & its applications
queue & its applicationsqueue & its applications
queue & its applicationssomendra kumar
 
Mca ii dfs u-3 linklist,stack,queue
Mca ii dfs u-3 linklist,stack,queueMca ii dfs u-3 linklist,stack,queue
Mca ii dfs u-3 linklist,stack,queueRai University
 
Bsc cs ii dfs u-2 linklist,stack,queue
Bsc cs ii  dfs u-2 linklist,stack,queueBsc cs ii  dfs u-2 linklist,stack,queue
Bsc cs ii dfs u-2 linklist,stack,queueRai University
 
unit 5 stack & queue.ppt
unit 5 stack & queue.pptunit 5 stack & queue.ppt
unit 5 stack & queue.pptSeethaDinesh
 
GAC DS Priority Queue Presentation 2022.ppt
GAC DS Priority Queue Presentation 2022.pptGAC DS Priority Queue Presentation 2022.ppt
GAC DS Priority Queue Presentation 2022.pptCUO VEERANAN VEERANAN
 
Queue - Data Structure - Notes
Queue - Data Structure - NotesQueue - Data Structure - Notes
Queue - Data Structure - NotesOmprakash Chauhan
 

Similar to Priority Queue (20)

DS UNIT2QUEUES.pptx
DS UNIT2QUEUES.pptxDS UNIT2QUEUES.pptx
DS UNIT2QUEUES.pptx
 
Data structures
Data structuresData structures
Data structures
 
Data structure using c module 3
Data structure using c module 3Data structure using c module 3
Data structure using c module 3
 
queue_final.pptx
queue_final.pptxqueue_final.pptx
queue_final.pptx
 
Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1
 
DS - Unit 2 FINAL (2).pptx
DS - Unit 2 FINAL (2).pptxDS - Unit 2 FINAL (2).pptx
DS - Unit 2 FINAL (2).pptx
 
Data Structures_ Sorting & Searching
Data Structures_ Sorting & SearchingData Structures_ Sorting & Searching
Data Structures_ Sorting & Searching
 
Queue
QueueQueue
Queue
 
Chapter 14 quick_sort
Chapter 14 quick_sortChapter 14 quick_sort
Chapter 14 quick_sort
 
List - Operations and Implementation
List - Operations and ImplementationList - Operations and Implementation
List - Operations and Implementation
 
Unit III Version I.pptx
Unit III Version I.pptxUnit III Version I.pptx
Unit III Version I.pptx
 
VCE Unit 03vv.pptx
VCE Unit 03vv.pptxVCE Unit 03vv.pptx
VCE Unit 03vv.pptx
 
queue & its applications
queue & its applicationsqueue & its applications
queue & its applications
 
Mca ii dfs u-3 linklist,stack,queue
Mca ii dfs u-3 linklist,stack,queueMca ii dfs u-3 linklist,stack,queue
Mca ii dfs u-3 linklist,stack,queue
 
Bsc cs ii dfs u-2 linklist,stack,queue
Bsc cs ii  dfs u-2 linklist,stack,queueBsc cs ii  dfs u-2 linklist,stack,queue
Bsc cs ii dfs u-2 linklist,stack,queue
 
unit 5 stack & queue.ppt
unit 5 stack & queue.pptunit 5 stack & queue.ppt
unit 5 stack & queue.ppt
 
Queues.ppt
Queues.pptQueues.ppt
Queues.ppt
 
Sorting
SortingSorting
Sorting
 
GAC DS Priority Queue Presentation 2022.ppt
GAC DS Priority Queue Presentation 2022.pptGAC DS Priority Queue Presentation 2022.ppt
GAC DS Priority Queue Presentation 2022.ppt
 
Queue - Data Structure - Notes
Queue - Data Structure - NotesQueue - Data Structure - Notes
Queue - Data Structure - Notes
 

Recently uploaded

(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAbhinavSharma374939
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxhumanexperienceaaa
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 

Recently uploaded (20)

(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog Converter
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 

Priority Queue

  • 1. 1 Presentation on Priority Queue Presented By: Md. Noyan Ali Dept. of CSE, KUET Presentation Date : May, 2018
  • 2. Definition : A priority queue is a collection of elements such that each elements has been assigned a priority and such that the order in which elements are deleted and processed comes from the following rules : 1. An element of higher priority is processed before any element of lower priority. 2. Two elements with the same priority are processed according to the order in which they were added to the queue. A prototype of a priority queue is a timesharing system : programs of high priority are processed first and programs with the same priority forma a standard queue. Implementation : There are two ways of representation of Priority Queue – 1. One-way List Representation of Priority Queue & 2. Array Representation of Priority Queue. Priority Queue
  • 3. INFO B D E A C G F PRN 2 4 4 1 2 5 4 LINK 6 4 9 1 3 0 8 5 2 1 2 3 4 5 6 7 8 9 10 11 12 AVAIL START A 1 G 5 X F 4 E 4 D 4 C 2 B 2 START One-Way List Representation of a Priority Queue :
  • 4. INFO B X D E A C G F PRN 2 2 4 4 1 2 5 4 LINK 6 3 4 9 1 2 0 8 5 7 1 2 3 4 5 6 7 8 9 10 11 12 AVAIL START A 1 G 5 X F 4 E 4 D 4 C 2 B 2 START One-Way List Representation of a Priority Queue – Insertion : X 2 Inserting Element X with Priority 2 :
  • 5. INFO B X D E C G F PRN 2 2 4 4 2 5 4 LINK 6 3 4 9 2 0 8 1 5 1 2 3 4 5 6 7 8 9 10 11 12 AVAIL START G 5 X F 4 E 4 D 4 C 2 B 2 START One-Way List Representation of a Priority Queue – Deletion : X 2 Deleting an Element :
  • 6. Algorithm for deletion : This algorithm deletes and processes the first element in a priority queue which appears in a memory as a one-way list - 1. Set ITEM = INFO[START]. [This saves the data in the first node.] 2. Delete first node from the list. 3. Process ITEM. 4. Exit. Algorithm for addition: This algorithm adds an ITEM with priority number N to a priority queue which is maintained in a memory as a one-way list - 1. Traverse the one-way list until finding a node X whose priority number exceeds N. ITEM in front of node X. 2. If no such node i found, insert ITEM as the last element of the list. Algorithms for One-Way List of PQ Operations :
  • 7. FRONT 2 1 0 5 4 REAR 2 2 0 1 4 1 2 3 4 5 1 2 3 4 5 6 1 A 2 B C 3 4 D E 5 G A 1 G 5 F 4 E 4 D 4 C 2 B 2 START Array Representation of a Priority Queue :
  • 8. FRONT 2 1 0 5 4 REAR 2 3 0 1 4 1 2 3 4 5 1 2 3 4 5 6 1 A 2 B C X 3 4 D E 5 G A 1 G 5 F 4 E 4 D 4 C 2 B 2 START Array Representation of a Priority Queue – Insertion : Inserting Element X with Priority 2 : C 2
  • 9. FRONT 0 1 0 5 4 REAR 0 3 0 1 4 1 2 3 4 5 1 2 3 4 5 6 1 A 2 B C X 3 4 D E 5 G G 5 X F 4 E 4 D 4 C 2 B 2 START Array Representation of a Priority Queue – Deletion : Deleting an Element : C 2
  • 10. Algorithm for deletion: This algorithm deletes and processes the first element in a priority queue maintained by a two-dimensional array QUEUE - 1. [Find the first nonempty queue.] Find the smallest k such that FRONT[k] != NULL. 2. Delete and process the front element in row k of queue. 3. Exit. Algorithm for addition: This algorithm adds an ITEM with priority number M to a priority queue maintained by a two-dimensional array QUEUE - 1. Insert ITEM as the rear element in row M of QUEUE. 2. Exit. Algorithms for Array Representation of PQ Operations :
  • 11. • Efficiency for array representation : The array representation of a priority queue is more time efficient than a one-way list. This is because when adding an element to a one-way list, one must perform a linear search on the list. • Efficiency for one-way list representation : The one-way list representation of a priority queue is more space efficient than the array representation. This is because in using the array representation, overflow occurs when the number of elements in any single priority level exceeds the capacity for that level, but in using one-way list representation , overflow occurs only when the total number of elements exceeds the total capacity.
  • 12. References : 1. Theory and Problems of DATA STRUCTURE – SEYMOUR LIPSCHUTZ. 2. http://btechsmartclass.com/DS/U3_T6.html. (accessed on 07 May, 2018)