Lesson 5.17 · Answer it
Messages sent offline
5 marksYou mark it yourself against the marking points
Ravi's phone has no signal on a train. Each message Ravi sends meanwhile waits in an outbox. When the signal comes back, the outbox sends the waiting messages one at a time. The outbox is a queue: a new message joins at the back.
On the train, Ravi sends three messages to a friend, in this order:
- "The train has stopped in a tunnel"
- "It could be an hour"
- "So start dinner without me"
(a) State the messages in the outbox, front first, just before the signal comes back. [1]
(b) The signal comes back. State which message is sent first, and name the queue operation that takes it out of the outbox. [2]
(c) Suppose the outbox were a stack instead. State the order in which the friend would get the three messages, and explain, using what the messages say, why that order is a problem. [2]
[5]