GATE Computer ScienceVery hardGATE CS (PYQ pattern)

A fully associative cache holds 4 blocks. A loop cycles through 5 distinct blocks 0,1,2,3,4,0,1,2,3,4,… for 30 references. How many hits does LRU produce, and how many would the optimal (Belady) policy produce?

  1. A. 19 and 0
  2. B. 1 and 19
  3. C. 0 and 16
  4. D. 0 and 19

Correct answer: D. 0 and 19

LRU (and FIFO) always evict exactly the block needed next, so a loop one block larger than the cache gets zero hits. OPT keeps most of the loop, evicting the block that is furthest away.

More Computer Organization and Architecture questions

Exams that ask this topic