Re: What is the minimum number of queues needed to implement the priority queue? A priority queue is a data structure for maintaining a collection of items each with an associated key (or priority). A priority queue supports the following operations:
* insert - add an item and its key to the priority queue
* maximum (or minimum) - return the item of highest priority
* extractMax (or extractMin) - remove the item of highest priority and return it
as well as the now standard isEmpty, isFull, and size operations.
If each item's priority is taken to be time at which it is inserted, then we get a first-in-first-out structure (i.e. a queue), thus the name priority queue.
What happens if two different items have the same priority? There are several options. As stated so far, there is no rule - so which ever item is extracted first is arbitrary. Alternatively, we can, as Main & Savitch do, treat the item that arrives first as if it had higher priority. In any case, this should be documented in specification of the priority queue. The minimum number of queues is one |