Belady's Anomaly: FIFO vs LRU vs Optimal, Checked in Python
Page replacement questions in GATE CS are mostly counting. You get a reference string, a number of frames and a policy, and you write a row of letters. The idea is easy; the marks go when you lose track of the oldest page late in the paper. So the useful skill is a method you can run without thinking, plus a way to check yourself on practice problems. I wrote a small Python checker for the second…
This article examines the Belady's anomaly phenomenon in page replacement algorithms, specifically FIFO, LRU, and Optimal policies. It provides a Python implementation for each of these methods to check and compare their performance on a given reference string with 3 and 4 frames. The reference string used for the example is 1 2 3 4 1 2 5 1 2.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.