UGC-NET | UGC NET CS 2017 Jan – II | Question 22

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


Answer: (B)

Explanation: 22
In fig:-1 elements are inserted into a stack then in fig:-2 top 5 elements are popped and these 5 elements are inserted into a queue which is shown in fig:-3, now first two elements are deleted from queue and pushed into stack one by one which is shown in fig:-5.
At top of the stack element B is presented.
So, option (B) is correct.

Quiz of this Question



My Personal Notes arrow_drop_up

Improved By : ShubhamMaurya3



Article Tags :

1


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.