Priority queue

A priority queue is a collection of elements such that each element has been assigned a priority and the order in which elements are deleted and processed comes from the following rules:

  • An element of higher priority is processed before any element of lower priority.
  • If two elements has same priority then they are processed according to the order in which they were added to the queue.

The best application of priority queue is observed in CPU scheduling.

  • The jobs which have higher priority are processed first.
  • If the priority of two jobs is same this jobs are processed according to their
    position in queue.
  • A short job is given higher priority over the longer one.

Continue reading “Priority queue”