18,668 views
10 10 votes

Stack A has the entries a, b, c (with a on top). Stack B is empty. An entry popped out of stack A can be printed immediately or pushed to stack B. An entry popped out of the stack B can be only be printed. In this arrangement, which of the following permutations of a, b, c are not possible?

  1. b a c
  2. b c a
  3. c a b
  4. a b c

2 Answers

Best answer
12 12 votes
ans is C  c a b is not possible
selected by
1 1 vote
CAB is also possible

Here is how

First pop C from stack a and push it to stack b

Then pop C from stack b and print

Then pop 2 times from stack a and push to stack b Then pop the rest and print

The resulting sequence is cab
Answer:
Position:
Show:

Related questions

4 4 votes
1 answers 1 answer
4.3k
4.3k views
go_editor asked Jun 13, 2016
4,295 views
A complete binary tree with the property that the value at each node is at least as large as the values at its children is known asbinary search treeAVL treecompletely ba...
5 5 votes
3 answers 3 answers
18.3k
18.3k views
go_editor asked Jun 13, 2016
18,254 views
Which of the following operations is performed more efficiently by doubly linked list than by linear linked list?Deleting a node whose location is givenSearching an unsor...
2 2 votes
1 answers 1 answer
19.4k
19.4k views
go_editor asked Jun 13, 2016
19,360 views
The time required to search an element in a linked list of length n is$O(\log_2 n)$$O(n)$$O(1)$$O(n^2)$
2 2 votes
5 answers 5 answers
23.7k
23.7k views
ajit asked Sep 20, 2015
23,662 views
The minimum number of fields with each node of doubly linked list is1234