Algorithms

Priority queue

A queue where what comes out isn't the first to arrive but the highest-priority one. It's almost always built with a heap.

Example

If tasks with priority 2, 9 and 5 arrive, the 9 comes out first. Adding and removing cost about 20 steps with 1 million tasks.

Test yourself: Priority queue

Heaps

What comes out of a priority queue first?

Lessons that use it

More algorithms terms

All terms →

Arki, the beaver mascot

Your next interview starts with 5 minutes today.

Free on iOS and Android. Start from zero, no account needed.