queue
The problem here sounds much like the one in Experiment #1: What happens if we input a bunch of words, push them all onto a queue, and then, as we pop them off, display them?
Try these out first:
Question #14.2.1: Suppose the words "Madam I'm Adam" were pushed one after the other onto the same queue, and then they were printed as they were popped off. What would be printed?
This is only one example but perhaps it's enough to make a prediction:
Question #14.2.2: What will the (eventual) program do in general to any sequence of words?
This is so similar to the stack
problem that we'll leave the
design to you. You should be able to copy the design for
Experiment #1 and just change a few words.
Question #14.2.3: What is the behavior of this program?
Question #14.2.4: What are the objects needed in the program?
Question #14.2.5: What are the operatios needed in the program? As we did in Experiment #1, you can ignore the old familiar input/output operations.
Question #14.2.6: What is the algorithm for this program?
Write the program, compile it, and run it.
Compare your prediction with the actual outcome.
Question #14.2.7: How closely did your prediction match the actual outcome?
Question #14.2.8: How does FIFO explain the behavior you see from your program?