A 2-way set-associative cache set holds blocks A and B. The access sequence is A, B, A, C. Under LRU replacement, which block does C replace?
Correct answer B. B
Explanation
After A, B, A the most recently used block is A and the least recently used is B, so C evicts B. FIFO would instead evict A, since A was loaded first, even though it was just reused. LRU exploits temporal locality: a block used recently is likely to be used again soon. Real caches often approximate LRU with cheaper pseudo-LRU bits.
Answer checked How we write and check questions
Discussion