📄 The question’s wording & key points
Problem Description: simulate a simple clinic waiting system with std::queue<std::string>. The program processes three kinds of actions:
1. ARRIVE <name> — a patient enters the queue (enqueue)
2. CALL — the doctor calls the patient at the front (dequeue) and prints their name; if the queue is empty, print "No patients waiting"
3. SHOW — print the name of the patient currently next in line without removing them (front / peek)
1ARRIVE = enqueue (push) — the new patient joins the rear
2CALL = dequeue (pop) — always the front; an empty queue must be reported
3SHOW = peek, never dequeue — the queue is completely unchanged
| Command | Queue operation | Output |
ARRIVE Alice | push(Alice) at the rear | Alice joined the queue |
CALL | front() then pop() | Now serving: Alice |
CALL (empty) | does nothing | No patients waiting |
SHOW | reads front() only | Next in line: Bob |
Why a queue? A clinic is first come, first served — that is exactly FIFO: enqueue at the rear, dequeue at the front. With a stack (LIFO) the last patient to arrive would be called first, which would scramble the order.
Complexity: push / pop / front are all O(1), so the whole simulation is O(number of commands).
Note: the slide’s "Example Actions" list is cut off in the photo, so the three sequences here are mine — each one covers all three actions and the empty-queue message.