ITPEC IP October 2021 Question 7

Source exam: ITPEC IP October 2021Topic: Algorithm and Programming

ITPEC IP October 2021 — Question 7 of 100

The second and therefore last removed value is 1. A queue is FIFO, so values leave in the same order they entered. After enqueuing 8, 1, 6, and 3, the first removal returns 8 and the second removal returns 1.

Answer (a)

Why not others:
- 3 and 6 remain behind the first two items

- 8 is removed first, not last among the two removals

Key rule: A queue removes from the front in insertion order; a stack removes from the top in reverse insertion order.

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.