It is pension day at a bank branch. By ten in the morning forty people are waiting, each holding a paper token, and the screen above the counter says "Now serving 27". Nobody argues about who goes next. The clerk calls the token that has been waiting longest, and when 27 is done, 28 is called. If the bank did it the other way round, calling whoever walked in last, the old man who arrived at nine would still be sitting there at closing time, and everybody would call that a broken system.
In the stack lesson you just read, the rule was exactly that other way round: the last item in is the first one out. That rule is perfect for the undo button and for the pile of function calls, and perfectly wrong for this counter. A line needs a different structure with a different rule, the queue: first in, first out. Printers, keyboards, CPU schedulers, ticket counters and the breadth-first search of a graph all run on it.
By the end of this chapter you'll be able to define a queue and work through its operations with overflow and underflow. You'll explain why a plain array queue wastes cells and how bending the array into a ring fixes it, and you'll trace FRONT and REAR through a circular queue without losing your place. You'll tell an empty ring from a full one in each of the three ways the books do it, use a deque with both its ends, and name which restricted deque allows what. You'll build a queue out of two stacks and a stack out of two queues and say what each costs. You'll keep a queue on a linked list with O(1) operations, put a stack and a queue side by side in a table, and say where queues are used.