Tutorials

Queue


Priority Queue


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

  1. Ascending priority queue
  2. 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.



Please Share this page
Views : 36
Like every other website we use cookies. By using our site you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service. Learn more Got it!