ITPEC IP October 2024 Question 9
On a desk that is only large enough to place four (4) files at the same time, six (6) files, A through F, are used to perform a task. When four (4) files are already placed on the desk, the least recently used file must be placed back into the drawer before the fifth file is placed on the desk. When the files are used in the sequence A, B, C, D, B, A, E, A, B, F, which of the following is the last file placed back into the drawer?
Explanation
D — under least-recently-used replacement, D is the file put back to make room for F, the last file brought to the desk.
Track the order of last use, oldest first:
- •A, B, C, D: the desk fills up
- •B, A: already on the desk, only their last use changes; order C, D, B, A
- •E: the desk is full, so C, the least recently used, goes back to the drawer; order D, B, A, E
- •A, B: already on the desk; order D, E, A, B
- •F: D is now the least recently used, so D goes back to the drawer — the last return in the sequence
Answer (c)
Why not others:
- •(a) A and (b) B — both were used immediately before F, making them the most recently used files on the desk
- •(d) E — was used (7th access) after D's last use (4th access), so D is the older one
Key rule: LRU evicts the item whose last use is oldest, and every use of an item already present refreshes it — track the order of last use, not the order of loading.
Software · AI-written, may contain errors
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.