CBSE NET January 2017 PAPER II
DATA STRUCTURE
Q. 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 ……………….
(A) A
(B) B
(C) F
(D) G
Ans :- (B)
Explanation:-
Push GFEDCBA
A
|
B
|
C
|
D
|
E
|
F
|
G
|
Pop 5 times and pop elements are queued EDCBA
|
|
|
|
|
F
|
G
|
2 elements deleted from queue, EDC, and pop in to stack
|
|
|
B
|
A
|
F
|
G
|
1 element pop from stack. That is B
|
|
|
|
A
|
F
|
G
|