How a Priority Queue a Queue Data Structure. Since it doesn't follow FIFO, shouldn't it be named Priority Array or Priority Linked LIst majorly because Priority Queues don't follow a fashion like a FIFO queue
A priority queue is a concept like a list or a map; just as a list can be implemented with a linked list or with an array, a priority queue can be implemented with a heap or with a variety of other methods such as an unordered array.
then why are they called priority Queue? – Ayush Srivastava. Oct 18, 2013 at 15:53. Because they are "queues" in the common (non-ADT) sense of the word: they are places where members arrive, wait for their turn, and then leave.
There are four different types of queues: Simple Queue. Circular Queue. Priority Queue.
The simplest queueing discipline is called FIFO, for "first-in-first-out." The most general queueing discipline is priority queueing, in which each customer is assigned a priority, and the customer with the highest priority goes first, regardless of the order of arrival.
In a priority queue, an element with high priority is served before an element with low priority. 'If two elements have the same priority, they are served according to their order in the queue' i think this will answer your question
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With