ITPEC IP April 2023 Question 6
ITPEC IP April 2023 — Question 6 of 100
After all four stack operations, the top-to-bottom values are 2 and 1. Initially the stack is [4,3,2,2,1]. Operation 1 replaces 4 and 3 with 7, giving [7,2,2,1]. Operation 2 pushes 3: [3,7,2,2,1]. Operation 3 replaces the top three with their average (3+7+2)÷3 = 4, giving [4,2,1]. Operation 4 replaces 4 and 2 with |4−2| = 2, leaving [2,1].
Answer (b)
Why not others:
- (a) omits the untouched bottom box
- (c) shows a 4 that operation 4 removes
- (d) leaves too many boxes, as if popped operands were retained
Key rule: A stack is LIFO: each operation removes its stated top operands and pushes exactly one result.
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.