ITPEC IP April 2020 Question 8

Source exam: ITPEC IP April 2020Topic: Algorithm and Programming

ITPEC IP April 2020 — Question 8 of 100

The final stack contains 1 at the bottom and 2 at the top. Initially it is 1,2,2,3,4 from bottom to top. Operation 1 replaces 3 and 4 with 7; operation 2 pushes 3. Operation 3 replaces 2,7,3 with their average 4. Operation 4 replaces 2 and 4 with their absolute difference 2.

Answer (b)

Why not others:
- the bottom 1 is never removed

- after each operation, removed boxes are replaced by only one new box, leaving exactly two boxes at the end

Key rule: A stack is LIFO, so every removal and insertion occurs at the top.

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.