CS FundamentalsVery hardProduct company interview · GATE level

Reference string: 2, 7, 2, 4, 1, 7, 3, 2, 4, 5, 1, 2, 7, 3, 5, 2. Three frames, initially empty, use LFU replacement: the victim is the resident page with the smallest total reference count so far (counts include references made while the page was not resident), and ties go to the page that was loaded earliest. How many page faults occur?

  1. A. 14
  2. B. 12
  3. C. 11
  4. D. 15

Correct answer: B. 12

Keep a running count per page. After 2, 7, 2, 4 the frames hold 2 (count 2), 7 and 4. On 1, the tie between 7 and 4 (count 1) is broken by load time, so 7 goes; then 7 itself faults and replaces 4 (count 1, oldest among the lowest). Continuing, page 2 gathers the highest count and is never evicted, which gives 2 fewer faults than FIFO's 14. Total 12. Resetting counts on eviction (a different LFU variant) changes the victims, which is why the rule is stated.

More Operating Systems questions

Exams that ask this topic