Question: (This question is for a Java class) In the following command sequence, numbered blocks are pushed and popped from a stack. Suppose that every time
(This question is for a Java class)
In the following command sequence, numbered blocks are pushed and popped from a stack. Suppose that every time a block is popped, its numerical value is printed. What is the sequence of values that are printed? Assume you begin with an empty stack: push block5; push block7; pop; pop; push block2; pop; push block1; pop; push block8; pop;
| A) | 8 1 2 7 5 | |
| B) | 7 5 2 1 8 | |
| C) | 5 7 2 1 8 | |
| D) | 7 5 8 1 2 | |
| E) | None of these is correct. |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
