page: {process_id,page_num,time}
before input:
RAM pages: {0,0,0},{0,1,0},{0,2,0},{0,3,0},{1,4,0},{1,5,0},{1,6,0},{1,7,0}
DISC pages: {0,99,0},{0,99,0},{0,99,0},{0,99,0},{1,99,0},{1,99,0},{1,99,0},{1,99,0},{2,99,0},{2,99,0},{2,99,0},{2,99,0},{3,99,0},{3,99,0},{3,99,0},{3,99,0}
input:
"0 2 1 3 3 2 2 0 2 1 0 2 3 0"
process 0
process 0 page table: {0,0,0},{0,1,0},{0,2,0},{0,3,0},{1,4,0},{1,5,0},{1,6,0},{1,7,0}
process 0 page table: {0,0,0 -> {0,99,0->1}},{0,1,0},{0,2,0},{0,3,0} // evict and replace smallest time step in RAM
process 0 page table: {0,99,1},{0,1,0},{0,2,0},{0,3,0} // evict and replace smallest time step in RAM
RAM total: {0,99,1},{0,1,0},{0,2,0},{0,3,0},{1,4,0},{1,5,0},{1,6,0},{1,7,0}
process 2
process 2 page table: {2,99,0},{2,99,0},{2,99,0},{2,99,0}
RAM total: {0,99,1},{0,1,0},{0,2,0},{0,3,0},{1,4,0},{1,5,0},{1,6,0},{1,7,0} // evict and replace smallest time step in RAM
RAM total: {0,99,1},{2,99,1},{0,2,0},{0,3,0},{1,4,0},{1,5,0},{1,6,0},{1,7,0} // evict and replace smallest time step in RAM
process 2 page table: {2,99,1},{2,99,0},{2,99,0},{2,99,0}
process 1
process 1 page table: {1,4,0},{1,5,0},{1,6,0},{1,7,0}
RAM total: {0,99,1},{2,99,1},{0,2,0 -> 1,4,0->1},{0,3,0},{1,4,0},{1,5,0},{1,6,0},{1,7,0} // evict and replace smallest time step in RAM
RAM total: {0,99,1},{2,99,1},{1,4,1},{0,3,0},{1,4,0},{1,5,0},{1,6,0},{1,7,0} // evict and replace smallest time step in RAM
process 1 page table: {1,4,1},{1,5,0},{1,6,0},{1,7,0}
process 3
process 3 page table: {3,99,0},{3,99,0},{3,99,0},{3,99,0}
RAM total: {0,99,1},{2,99,1},{1,4,1},{0,3,0 -> 3,99,0->1},{1,4,0},{1,5,0},{1,6,0},{1,7,0} // evict and replace smallest time step in RAM
RAM total: {0,99,1},{2,99,1},{1,4,1},{3,99,1},{1,4,0},{1,5,0},{1,6,0},{1,7,0} // evict and replace smallest time step in RAM
process 3 page table: {3,99,1},{3,99,0},{3,99,0},{3,99,0}
process 3
process 3 page table: {3,99,1},{3,99,0},{3,99,0},{3,99,0}
RAM total: {0,99,1},{2,99,1},{1,4,1},{3,99,1},{1,4,0 -> 3,99,0->1},{1,5,0},{1,6,0},{1,7,0} // evict and replace smallest time step in RAM
RAM total: {0,99,1},{2,99,1},{1,4,1},{3,99,1},{3,99,1},{1,5,0},{1,6,0},{1,7,0} // evict and replace smallest time step in RAM
process 3 page table: {3,99,1},{3,99,1},{3,99,0},{3,99,0}
process 2
process 2 page table: {2,99,0},{2,99,0},{2,99,0},{2,99,0}
RAM total: {0,99,1},{2,99,1},{1,4,1},{3,99,1},{3,99,1},{1,5,0 -> 2,99,0->1},{1,6,0},{1,7,0} // evict and replace smallest time step in RAM
RAM total: {0,99,1},{2,99,1},{1,4,1},{3,99,1},{3,99,1},{2,99,1},{1,6,0},{1,7,0} // evict and replace smallest time step in RAM
process 2 page table: {2,99,1},{2,99,1},{2,99,0},{2,99,0}
process 2
process 2 page table: {2,99,1},{2,99,1},{2,99,0},{2,99,0}
RAM total: {0,99,1},{2,99,1},{1,99,1},{3,99,1},{3,99,1},{2,99,1},{1,6,0 -> {2,99,0->1}},{1,7,0} // evict and replace smallest time step in RAM
RAM total: {0,99,1},{2,99,1},{1,4,1},{3,99,1},{3,99,1},{2,99,1},{2,99,1},{1,7,0} // evict and replace smallest time step in RAM
process 2 page table: {2,99,1},{2,99,1},{2,99,1},{2,99,0}
process 0
process 0 page table: {0,99,1},{0,1,0},{0,2,0},{0,3,0}
RAM total: {0,99,1},{2,99,1},{1,99,1},{3,99,1},{3,99,1},{2,99,1},{1,6,0 -> {0,99,0->1}},{1,7,0} // evict and replace smallest time step in RAM
RAM total: {0,99,1},{2,99,1},{1,4,1},{3,99,1},{3,99,1},{2,99,1},{0,99,1},{1,7,0} // evict and replace smallest time step in RAM
process 0 page table: {0,99,1},{0,1,0},{0,2,0},{0,3,0}
process 2
process 2 page table: {2,99,1},{2,99,1},{2,99,1},{2,99,0}
RAM total: {0,99,1},{2,99,1},{1,99,1},{3,99,1},{3,99,1},{2,99,1},{2,99,1},{1,7,0 -> {2,99,0->1}} // evict and replace smallest time step in RAM
RAM total: {0,99,1},{2,99,1},{1,4,1},{3,99,1},{3,99,1},{2,99,1},{0,99,1},{2,99,1} // evict and replace smallest time step in RAM
process 2 page table: {2,99,1},{2,99,1},{2,99,1},{2,99,1}
process 1
process 1 page table: {1,4,1},{1,5,0},{1,6,0},{1,7,0}
RAM total: {0,99,1 -> {1,5,0->1}},{2,99,1},{1,4,1},{3,99,1},{3,99,1},{2,99,1},{2,99,1},{2,99,1} // evict and replace smallest time step in RAM
RAM total: {1,5,1},{2,99,1},{1,4,1},{3,99,1},{3,99,1},{2,99,1},{0,99,1},{2,99,1}
process 1 page table: {1,4,1},{1,5,1},{1,6,0},{1,7,0}
process 0
process 0 page table: {0,99,1},{0,1,0},{0,2,0},{0,3,0}
RAM total: {{1,5,1} -> {0,99,0->1}},{2,99,1},{1,4,1},{3,99,1},{3,99,1},{2,99,1},{2,99,1},{2,99,1} // evict and replace smallest time step in RAM
RAM total: {0,99,1},{2,99,1},{1,4,1},{3,99,1},{3,99,1},{2,99,1},{0,99,1},{2,99,1}
process 0 page table: {0,99,1},{0,1,0},{0,2,0},{0,3,0}
process 2
process 2 page table: {2,99,1},{2,99,1},{2,99,1},{2,99,1}
RAM total: {0,99,1 -> {2,99,0->1}},{2,99,1},{1,4,1},{3,99,1},{3,99,1},{2,99,1},{0,99,1},{2,99,1} // evict and replace smallest time step in RAM
RAM total: {2,99,1},{2,99,1},{1,4,1},{3,99,1},{3,99,1},{2,99,1},{0,99,1},{2,99,1}
process 2 page table: {2,99,1},{2,99,1},{2,99,1},{2,99,1}
process 3
process 3 page table: {3,99,1},{3,99,1},{3,99,0},{3,99,0}
RAM total: {2,99,1 -> {3,99,0->1}},{2,99,1},{1,4,1},{3,99,1},{3,99,1},{2,99,1},{0,99,1},{2,99,1} // evict smallest time step from RAM
RAM total: {3,99,1},{2,99,1},{1,4,1},{3,99,1},{3,99,1},{2,99,1},{0,99,1},{2,99,1} // bring in least recently used page into RAM
process 3 page table: {3,99,1},{3,99,1},{3,99,1},{3,99,0}
process 0
process 0 page table: {0,99,1},{0,1,0},{0,2,0},{0,3,0}
RAM total: {3,99,1 -> {0,99,0->1}},{2,99,1},{1,4,1},{3,99,1},{3,99,1},{2,99,1},{2,99,1},{2,99,1} // evict and replace smallest time step in RAM
RAM total: {0,99,1},{2,99,1},{1,4,1},{3,99,1},{3,99,1},{2,99,1},{2,99,1},{2,99,1} // evict and replace smallest time step in RAM
process 0 page table: {0,99,1},{0,1,0},{0,2,0},{0,3,0}
{0,99,1},{2,99,1},{1,4,1},{3,99,1},{3,99,1},{2,99,1},{2,99,1},{2,99,1}
my output
0 99 1 2 3
1 4 5 6 7
2 99 99 99 99
3 99 99 99 99
0,99,1;2,99,1;1,4,1;3,99,1;3,99,1;2,99,1;2,99,1;2,99,1;
correct output
0 99 99 99
1 99 99 99
2 99 99 99
3 99 99 99
0,0,0;0,0,0;1,0,1;1,0,1;2,0,2;2,0,2;3,0,3;3,0,3;Empty;Empty;Empty;Empty;Empty;Empty;Empty;Empty;