Priority queue is designed in such a way that each element that it holds are assigned certain priority.
The order in which the operation on the element in the priority queue is determined by the priority that it holds.
Rules of priority queue
An element with higher priority should be processed before any element that has lower priority.
In case two or more element has same priority then they are processed according to the order in which they were added to the queue.
Types of priority queue
Based on implementation there are two types of priority queue
Ascending priority queue
Descending priority queue
Ascending priority queue is a collection of elements in which elements can be inserted arbitrarily and from which only smallest element can be removed.
Descending priority queue is a collection of elements in which elements can be inserted arbitrarily and from which only largest element can be removed.