The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
+14 votes

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$
asked in DS by Veteran (68.8k points)
edited ago by | 535 views

3 Answers

+17 votes
Best answer

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

So, Output will be $20, 20, 10, 10, 20$

answered by Veteran (14k points)
edited ago by
+12 votes
Nothing to explain. It will be B.
answered by Veteran (19.5k points)
+1 vote
Just simple push pop operation option B
answered by Boss (9.5k points)

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

32,330 questions
39,146 answers
36,501 users