Knowee
Questions
Features
Study Tools

Select the correct answerStack M has the entries 1,2,3(with a on top).Stack N is empty.An entry popped out of stack M can be printed immediately or pushed to stack N.An entry popped out of the stack N can only be printed. In this arrangement, which of the following permutations of 1,2,3 are not possible?Options1,2,32,1,33,2,13,1,2

Question

Select the correct answerStack M has the entries 1,2,3(with a on top).Stack N is empty.An entry popped out of stack M can be printed immediately or pushed to stack N.An entry popped out of the stack N can only be printed. In this arrangement, which of the following permutations of 1,2,3 are not possible?Options1,2,32,1,33,2,13,1,2

🧐 Not the exact question you are looking for?Go ask a question

Solution

The question is about the possible permutations of the numbers 1,2,3 in a specific stack arrangement.

The rules are:

  1. An entry popped out of stack M can be printed immediately or pushed to stack N.
  2. An entry popped out of the stack N can only be printed.

Given these rules, let's go through each option:

  1. 1,2,3: This is possible. Pop 1 from M and print, pop 2 from M and print, pop 3 from M and print.
  2. 2,1,3: This is possible. Pop 1 from M and push to N, pop 2 from M and print, pop 1 from N and print, pop 3 from M and print.
  3. 3,2,1: This is not possible. No matter how you pop and push, you can't get 3 to be the first number printed.
  4. 3,1,2: This is possible. Pop 1 from M and push to N, pop 2 from M and push to N, pop 3 from M and print, pop 2 from N and print, pop 1 from N and print.

So, the permutation that is not possible with this stack arrangement is 3,2,1.

This problem has been solved

Similar Questions

Stack M has the entries 1,2,3(with a on top).Stack N is empty.An entry popped out of stack M can be printed immediately or pushed to stack N.An entry popped out of the stack N can only be printed. In this arrangement, which of the following permutations of 1,2,3 are not possible?Options3,1,21,2,32,1,33,2,1

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?

Select the correct answerWhich of the following permutations can be obtained in the output(in the same order),using a stack assuming that the input is the sequence A,B,C,D,E in that order?OptionsC,D,E,B,AC,D,A,B,EC,D,A,E,BC,D,E,A,B

Select the correct answerUsing Pop (S1,Item) ,Push(S1, Item), Getlist(Item), Pop(S2,Item), and the variables S1,S2(stacks with Top1 and Top2) and Item and given the input file: A,B,C,D,E,F Which stack are possible?OptionsAll possible stacks with A,B,C,D,E and FExact and only those stacks which can be produced with S1 aloneTwice as many stacks as can be produced with S1 aloneNo possible stacks with A,B,C,D,E and F

Select the correct answerFollowing sequence of operations is performed on a stack push(6),push(7),pop, push(5),push(4)pop,pop,pop,push(3),pop.The sequence of poped out values areOptions7,4,5,6,37,4,5,3,67,5,4,6,33,4,5,6,7

1/2

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.