215k views
4 votes
A stack is initially empty, then the following commands are performed: push 5, push 7, pop, push 10, push 5, pop , which of the following is the correct stack after those commands (assume the top of the stack is on the left)?

a. 10 7 8 5 9
b. 10 8 5
c. 8 5 9
d. 8 5

1 Answer

4 votes

Answer:

The answer is "5, 10".

Step-by-step explanation:

In this question values are different that's why all choice was wrong, it correct solution can be defined as follows:

In the stack, we use the "push and pop" method that works as follows:

  • Push is used to inserting the value into the stack.
  • Pop is used for deleting the value from the stack.
A stack is initially empty, then the following commands are performed: push 5, push-example-1
User Ben Voigt
by
5.3k points