Queue discipline
Introduction / Definition
Queue discipline normally follows first-in-first-out order. The earliest inserted item is removed first. Queues model waiting lines, buffering, scheduling, and breadth-first search. Efficient queues maintain front and rear positions.
Syntax / Structure / Formula
enqueue(x); dequeue(); front();
Detailed Explanation
Enqueue adds at the rear and dequeue removes from the front. Circular arrays or linked nodes avoid repeated shifting.
Example
Example: Enqueue A, B, C, then dequeue once.
Output / Result
A is removed first; B and C remain.
Important Points / Notes
- FIFO.
- Consider empty/full conditions for bounded queues.
Mini Practice Question
What is removed first after A, B, C are enqueued?
CheckpointTest Yourself