algorithms

Algorithms Handbook

View on GitHub

Priority Queue

Overview

Priority Queue is an extension of queue with the following properties:

  1. Every item has a priority associated with it.
  2. An element with high priority is dequeued before an element with low priority.
  3. If two elements have the same priority, they are served according to their order in the queue.

In this example, element with maximum ASCII value will have the highest priority.

Applications

Common Procedures

Design & Implementation

Array Implementation

Heap Implementation

Implementation Examples

Java

java.util provides PriorityQueue<E> class that implements Serializable, Iterable<E>, Collection<E>, Queue<E> interfaces.

Some important points:

See more examples in my [Datastructures in Java repository]((https://github.com/herrera-ignacio/datastructures-in-java/tree/master/src/main/java/linear/queue)