230k views
3 votes
If you were to push 10, 20, and 30 onto a stack in this order and then pop them off, in what order will they be removed from the stack?

User Lekroif
by
8.4k points

1 Answer

2 votes

The numbers will be removed in the order 30, 20, 10.

In a stack the last one in is the first one out (LIFO strategy). So, if we enter 10, 20 and 30 we will get out 30, 20 and 10.

Please check the image I drew for you.

  • The top is showing the content of the stack after any operation
  • The bottom text is what is happening during the operation
If you were to push 10, 20, and 30 onto a stack in this order and then pop them off-example-1
User Samuelesque
by
8.5k points