THINK FIRST·CODE LATER

← All labs

Fault curves and Belady's anomaly

Problem

Input: maxFrames, then a reference string.

For every number of frames f = 1 … maxFrames, count the faults of FIFO and LRU and print a table:

frames  FIFO  LRU
     1    12   12
     2    12   12
     3     9   10

(format %6d %4d %3d). Then print Belady anomaly (FIFO faults increase): 3->4 listing every f−1->f where FIFO's faults increased (comma-separated), or No Belady anomaly.

Write it here or in your IDE, then paste it. Compile and test it yourself before comparing. Your code stays in your browser — it is never sent to or stored on the server.