Skip to content
Related Articles

Related Articles

GATE | GATE 2017 MOCK II | Question 22
  • Last Updated : 14 Feb, 2018

Linked Questions 22-23

Stack A has the entries as following sequence a, b, c (with ‘a’ on top), stack B is empty, as shown in the diagram below.

stack

An entry popped out of stack A can be printed or pushed to stack B. An entry popped out of stack B can only be printed.

In this arrangement which of the following permutation of a, b, c are not possible to print?



(i)   bac
(ii)  bca
(iii) cab
(iv)  abc

(A) (i), (ii) and (iii)
(B) (iv) Only
(C) (iii) Only
(D) (ii) and (iii) Only


Answer: (C)

Explanation: Follow these steps to print bac.

1) POP element ‘a’ from stack A, push ‘a’ to Stack B.
2) POP element ‘b’ from A, print it.
3) POP element ‘a’ from B, and print it.
4) POP element ‘c’ from A, and print it.
Now, perumtation bac has been printed.

Similarly, we can print bca and abc, but can’t print cab.

Quiz of this Question

sudo-gate-course

My Personal Notes arrow_drop_up
Recommended Articles
Page :