The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
0 votes
549 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 (342k points) | 549 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.1k 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

35,518 questions
42,792 answers
121,605 comments
42,162 users