The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
0 votes
901 views

The seven elements A, B, C, D, E, F and G are pushed onto a stack in reverse order, i.e., starting from G. The stack is popped five times and each element is inserted into a queue. Two elements are deleted from the queue and pushed back onto the stack. Now, one element is popped from the stack. The popped item is ________

  1. B
  2. F
  3. G
asked in Others by Veteran (363k points) | 901 views

2 Answers

+2 votes
Best answer

push G F E D C B A :

Stack is : 

A

B

C

D

E

F

G

pop 5 times

F

G

insert popped in queue:  (rear)   E D C B A (front)

delete 2 from queue: (rear)   E D C  (front)

push in stack

B

A

POP 1: B

so answer is B

option 2

answered by Active (3.9k points)
selected by
+1 vote

Option is B

answered by Active (1.7k points)

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

42,685 questions
48,650 answers
156,447 comments
63,961 users