A priority queue is conceptually an array of queues, indexed by priority. To remove an item from the priority queue, the first item of the highest-priority non-empty queue is removed and returned.
In an operating system, there often is a fixed and small number of priorities. A high-priority process, such as responding to a device interrupt, can interrupt a lower-priority process such as a user program. The processes that are ready to run are kept on a priority queue. The high-priority processes are short but need fast service. Whenever a process ceases execution, the operating system removes the next highest-priority process from the ready queue and runs it.
If we use an array of circular queues or two-pointer queues, both insertion and removal are O(1).
We will assume that the highest-priority item is the one with the lowest priority number. The operations on the priority queue are insert and deleteMin. (We will discuss a min queue; a max queue could be implemented similarly.)
Contents    Page-10    Prev    Next    Page+10    Index