The Gateway to Computer Science Excellence
+22 votes
1.4k views

Choose the correct alternatives (more than one may be correct) and write the corresponding letters only:

The following sequence of operations is performed on a stack:

PUSH  (10), PUSH (20), POP, PUSH (10), PUSH (20), POP, POP, POP, PUSH (20), POP

The sequence of values popped out is

  1. $20,10,20,10,20$
  2. $20,20,10,10,20$
  3. $10,20,20,10,20$
  4. $20,20,10,20,10$
in DS by
edited by | 1.4k views

5 Answers

+27 votes
Best answer

Let us try something different when you read the word pop then delete the last pushed element and print it. Now ,delete the push word which we have already executed. Now, go on from left to right and do the same.

So, output will be $20, 20, 10, 10, 20$.

Correct Answer: $B$

by
edited by
+16 votes
Nothing to explain. It will be B.
by
+4 votes
Just simple push pop operation option B
by
+2 votes

20 20 10 10 20

by
edited by
0 votes
by

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
52,345 questions
60,510 answers
201,930 comments
95,354 users