Covers IGNOU MCS-208 §Programme guide topic "Priority Queues" (not in the Unit 5 booklet)
In a hospital emergency room, patients are not treated strictly in arrival order: the most serious case goes first. A priority queue is the data structure for this rule.
The idea
Operations: insert(Q, x, p) adds item x with priority p; delete_min(Q) (or delete_max) removes and returns the most urgent item; peek(Q) returns it without removing it.
Implementations
Implementation
insert
delete most urgent
Notes
Unsorted array or list
O(1): add at the end
O(n): search for it
Good when deletions are rare
Sorted linked list
O(n): find the place
O(1): it is the first node
Simple; keeps ties in FIFO order
Binary heap (array)
O(logn)
O(logn)
The standard choice (Unit 9)
One queue per priority level
O(1)
O(k) for k levels
Good for a few fixed levels (OS scheduling)
Applications
CPU scheduling by process priority.
Shortest-path algorithms such as Dijkstra’s (Unit 8) repeatedly take the closest unvisited vertex.
Event-driven simulation: events are processed in order of their time.
Bandwidth management: urgent network packets (e.g. voice) are sent before bulk data.
Key takeaways
Priority queue: delete returns the highest-priority item; ties are usually FIFO.
Used in scheduling, Dijkstra’s algorithm, simulation and networking.
Practice questions
Answer on paper first, then check. The explanation matters more than the letter you chose.
Question 6 · short answer
Explain how a priority queue differs from an ordinary queue and give two applications.
Show worked answer
An ordinary queue removes items in the order they were inserted (FIFO). A priority queue gives every item a priority and always removes an item with the highest priority (e.g. the smallest priority number); arrival order matters only between items of equal priority. Applications: (1) CPU scheduling, where higher-priority processes run first; (2) Dijkstra’s shortest-path algorithm, which repeatedly removes the vertex with the smallest distance; (3) event-driven simulation, which processes events in order of time.
MCA Online notes are made for reading on screen. Open https://mcastudy.online/mcs-208/queues/priority-queues/ to read this page.