10,533 views
5 votes
5 votes

The five items: A, B, C, D, and E are pushed in a stack, one after other starting from A. The stack is popped four items and each element is inserted in a queue. The two elements are deleted from the queue and pushed back on the stack. Now one item is popped from the stack. The popped item is

  1. A
  2. B
  3. C
  4. D

2 Answers

Best answer
19 votes
19 votes

Initially A, B, C, D, and E are pushed in a stack, one after other starting from A.

Stack is popped four items.

Four element is inserted in a queue. The two elements are deleted from the queue

Two elements are pushed back on the stack.Now one item is popped from the stack. The popped item is D.

Correct option is D.

selected by
0 votes
0 votes
e

d

c

b

a

elements in the stack(pile of glasses, LIFO order, last element inserted will be the first to delete  ) initially

now 4 elements are popped out in order e d c b

now they are inserted into the queue so now the order of q is e d c b

in the queue, we delete from first element (FIFO  in reservation counter who comes first goes first)

now delete 2 elements  so e and d are deleted respectively

now insert the elements into stack in the order which they are deleted

so now stack is

d

e

a

now pop one element i.e is d
Answer:

Related questions

4 votes
4 votes
2 answers
1
go_editor asked Jun 14, 2016
3,467 views
The infix expression $A+(B-C)^*D$ is correctly represented in prefix notation as$A+B-C^*D$$+A^*-BCD$$ABC-D^*+$$A+BC-D^*$
32 votes
32 votes
5 answers
2
Kathleen asked Sep 18, 2014
12,895 views
Assume that the operators $+, -, \times$ are left associative and $^\hat{}$ is right associative. The order of precedence (from highest to lowest) is $ \ ^\hat{}, \times,...
8 votes
8 votes
2 answers
3
go_editor asked Jun 10, 2016
7,791 views
On a system using non-preemptive scheduling, processes with expected run times of 5, 18, 9 and 12 are in the ready queue. In what order should they be run to minimize wai...
6 votes
6 votes
1 answer
4
Desert_Warrior asked Jun 3, 2016
6,562 views
Substitution of values for names (whose values are constants) is done inLocal optimizationLoop optimizationConstant foldingStrength reduction