The numbers 1, 2 and 3 are pushed onto a stack in this order (1 is pushed first), and pop operations may be freely interleaved between the pushes. Each popped number is written down in the order of popping. Which of the following output sequences CANNOT be produced by any valid interleaving of the pushes and pops?
3, 1, 2
1, 3, 2
2, 3, 1
3, 2, 1
The verified answer and full solution are one login away
Every answer here is machine verified, with a step-by-step solution that teaches the method. Your login also unlocks a 7-question mock preview in the real exam interface.
Log in to see the answerMore data structures questions