Input: delta frames nProc, then one line of page references per process (all lines have the same length; at each time step every process makes one reference).
For each time t = 1 … n, compute each process's working set (distinct pages among its last delta references, up to t) and the total demand D. Print:
t=7: P0[1,2,3,4]=4 P1[10,11,12,13]=4 | D=8 > 7 THRASHING RISK
(sets sorted, without spaces; the suffix > frames THRASHING RISK only when D > frames). Then Peak demand D at t=T, frames F, overloaded steps K (first time the peak is reached) and either Advice: suspend Pi (working set s) to free frames — the process with the largest working set at the peak time (lowest index on ties) — if the peak exceeds the frames, or Advice: all working sets fit.