ITPEC IP October 2023 Question 8
ITPEC IP October 2023 — Question 8 of 100
A queue removes values in first-in, first-out order, so the two removals are 8 followed by 1. The insertion order is 8, 1, 6, 3. The first dequeue removes the oldest element, 8; the second dequeue then removes the next oldest element, 1. Therefore, the last of the two removed values is 1.
Answer (a)
Why not others:
- (b) 3 was inserted last and remains at the rear
- (c) 6 is third in the queue and would be removed on the third dequeue
- (d) 8 is removed first, not last among the two removals
Key rule: A queue is FIFO: enqueue at the rear and dequeue from the front. A stack, by contrast, is LIFO.
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.