Skip to main content

Priority Queue

Learn Priority Queue (Queue / Deque, Data Structures & Algorithms) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

What is a Priority Queue? Unlike a regular queue (FIFO order), a priority queue always returns the element with the HIGHEST PRIORITY first - in Java, that means the SMALLEST element by default (a min-heap). offer and poll are both O(log n).

More lessons in Queue / Deque