Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1
A queue usually means that the order of adding and removing with the container follows FIFO (first in first out) similar to people lined up at a grocery store. A queue normally selects the oldest inserted value for removal. A priority queue removes elements based on some other rule. It'll select based on "priority" and you define what priority means. A priority can be defined by a comparison function that says what of any 2 arbitrary elements has higher "priority". What happens if the highest priority is always the oldest time inserting an element? Well, that priority queue is also a very conventional queue. FIFO and non-FIFO order is the critical difference between a conventional queue and a priority queue. Beyond that, usually the data-structures are different for more efficiency. For example, a linked list is great for a conventional queue but a heap is great for a priority queue.
4th Sep 2020, 6:54 PM
Josh Greig
Josh Greig - avatar