120 views

Elements $1,2,3,4,5$ are inserted in a stack in sequence. The elements are printed while popping them out. Which of the following is a wrong print sequence?

1. $3 \ 5 \ 4 \ 2 \ 1$
2. $1 \ 3 \ 2 \ 4 \ 5$
3. $5 \ 4 \ 3 \ 2 \ 1$
4. $2 \ 4 \ 1 \ 5 \ 3$

i think here A and C is corrrect.........but not B.........so its A option is correct plz check??

yes, you are right, it had multiple answers correct A and C.

Changed that question as that had multiple answers and also was one line question.

please provide a solution, I'm noting this. The link given is also something else, not related to question.

Elements $1,2,3,4,5$ are inserted in a stack in sequence.

For option $(A)$: push(1),push(2),push(3),pop,push(4),push(5),pop,pop,pop,pop$\implies3,5,4,2,1$

For option $(B)$: push(1),pop,push(2),push(3),pop,pop,push(4),pop,push(5),pop$\implies1,3,2,4,5$

For option $(C)$: push(1),push(2),push(3),push(4),push(5),pop,pop,pop,pop,pop$\implies5,4,3,2,1$

For option $(D)$: push(1),push(2),pop,push(3),push(4),pop after that we required $1$,but we can pop only $3$.And if we push(5),then we get $5$.

So, $2,4,1,5,3$ is not got at any operation we performed.

So,the correct answer is $(D)$.