ITPEC IP April 2024 Question 8
ITPEC IP April 2024 — Question 8 of 100
The removal order C, A, B is impossible with one stack. A stack is last-in, first-out (LIFO). To remove C first, all three arriving products must have been pushed, leaving A at the bottom, B above A, and C on top. After popping C, B is still above A, so B must be removed before A; A cannot be the second item.
The other orders can be produced by choosing suitable times to pop: A, B, C by popping each item before the next arrives; B, A, C by pushing A and B, then popping both before C; and C, B, A by pushing all three and popping them in reverse order.
Answer (c)
Why not others: (a), (b), and (d) each have a valid sequence of PUSH and POP operations as described above.
Key rule: Once one item lies below another in a stack, the upper item must be popped first; a single stack cannot bypass it.
AI-generated — may contain errors
The original exam layout is preserved in the image so diagrams, formulas, tables, and code remain accurate.
This question comes from an official ITPEC past paper. ITPEC Practice is an independent study tool and is not affiliated with ITPEC. See the official IP past-paper collection or Report an issue.