6 6 votes Suppose an intermixed sequence of stack push and pop operations is performed. The push operations push the integers $0$ through $9$ in order. The pop operations print the returned values.Which of the following output sequences could NOT occur?$\texttt{4 3 2 1 0 9 8 7 6 5}$$\texttt{4 6 8 7 5 3 2 9 0 1}$$\texttt{2 5 6 7 4 8 9 3 1 0}$$\texttt{4 3 2 1 0 5 6 7 8 9}$$\texttt{1 2 3 4 5 6 9 8 7 0}$$\texttt{0 4 6 5 3 8 1 7 2 9}$$\texttt{1 4 7 9 8 6 5 3 0 2}$$\texttt{2 1 4 3 6 5 8 7 9 0}$ Data Structures goclasses goclasses-da-dpp goclasses-da-dpp-day-219 goclasses-cs-dpp goclasses-cs-dpp-day-319 data-structures python-&-dsa goclasses-python-&-dsa-practice-questions goclasses-ds-practice-questions stack multiple-selects + – GO Classes 358 views answer comment Share Follow Print 0 reply Please log in or register to add a comment.
1 1 vote A stack follows LIFO order. Once a larger later item is pushed above smaller earlier items, the lower item cannot be popped before the items above it.In option B, after producing part of the sequence, $1$ blocks $0$, so $0$ cannot come before $1$.In option F, after some required pushes, an item below the stack is demanded before the item above it. This violates LIFO order.In option G, the output asks for $0$ before $2$, even though $2$ is above $0$ on the stack at that stage.Therefore, the impossible sequences are B, F and G. GO Classes answered Jul 9 GO Classes comment Share Follow 0 reply Please log in or register to add a comment.
1 1 vote Answer: B, F, G Meticulous_March answered Jul 10 Meticulous_March comment Share Follow 0 reply Please log in or register to add a comment.
0 0 votes In B 0 is coming before 1 not possible In F 1 is coming before 2 not possibleIn G 0 is coming before 2 not possibleSo answer is B, F , G Vivid_Vivek answered Jul 10 Vivid_Vivek comment Share Follow 0 reply Please log in or register to add a comment.