ITPEC IP October 2025 Question 5

Topic: SoftwareAlso asked in April 2019, Spring 2021 and October 2022

There is a desk that can hold at most four (4) files. On this desk, six (6) files A through F are used for a job. When the fifth file needs to be put on the desk, the file with the longest time since the last use among the four (4) will be put in a drawer. If the files are put on the desk and referenced in order of A, B, C, D, E, C, B, D, F, B, which of the following is the last file to be put in the drawer?

Explanation

E — the desk works like LRU page replacement: when a fifth file is needed, the file unused for the longest time goes to the drawer.

Trace the references with the desk's last-use times (reference numbers 1 to 10):

  • •A, B, C, D (1–4) fill the desk
  • •E (5): the desk is full; A was used longest ago, so A goes to the drawer. Desk: B, C, D, E
  • •C (6), B (7), D (8) are already on the desk; they only refresh their last-use times
  • •F (9): last uses are B 7, C 6, D 8, E 5, so E goes to the drawer
  • •B (10) is on the desk; nothing moves

Two files go to the drawer, A then E, so the last one is E.

Answer (d)

Why not others:

  • •(a) A — the first file put in the drawer, when E arrives, not the last
  • •(b) B — the file that has been on the desk longest (FIFO); the rule looks at the time since last use, and B was just used at reference 7
  • •(c) D — the most recently used file, reference 8: evicting it inverts the rule

Key rule: LRU evicts by the time of the last use, not of arrival; a reference to a file already present moves nothing but renews its last-use time.

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.