Overview of Priority Queue

 Consider a group of patients waiting outside the doctor's cabin for consultation. The functioning of the clinic is First In First Out basis like a queue. Suddenly, a new patient arrives with a condition which requires immediate treatment. 


Then, the doctor would treat this patient first and then continue treating other patients like the previous order.

In a priority queue, each data element has priority. So that crucial data does not get stuck. High priority elements are dequeue before low priority elements. If multiple elements have the same priority number, then the deletion is on a first come first serve basis.


When array implements a priority queue, an additional 2-D array is required to store the priority.

When a linked list implements a priority queue, the node stores the priority number.


Applications of priority queue:

  1. Bandwidth management.
  2. Dijkstra Algorithm.
  3. Huffman Coding.
  4. Best First Search Algorithm.
  5. CPU Scheduling

Comments

Popular posts from this blog

Overview of Tree Data Structure

Overview of Three Dimensional Array