Chapter 9
These are the solutions to the exercises found in the section Exercises.
-
Presumably, we’d want to be nice to the callers and answer their phone calls in the order in which they were received. For this we’d use a queue, which processes data FIFO (first in, first out).
-
We’d be able to read the 4, which is now the top element in the stack. This is because we’ll have popped the 6 and the 5, which were previously sitting on top of the 4.
-
We’d be able to read the 3, which is now at the front of the queue, after having dequeued the 1 and the 2.
-
We can take advantage of the stack because of the fact that we pop each item in the reverse order of which they were pushed onto the stack. So we’ll first push each character of the string onto the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access