← Quiz: Page Replacement Numericals: all 15 questions
Quiz: Page Replacement Numericals · Question 8 of 15
What does this print? (code)
What does this print?
refs = [1, 2, 1, 3, 1, 2]
mem, f = [], 0
for p in refs:
if p not in mem:
f += 1
if len(mem) == 2:
mem.pop(0)
mem.append(p)
print(f)
- A.3
- B.4
- C.5
- D.6
Answer & explanation
Correct answer: 5
This is FIFO with 2 frames: 1 F, 2 F, 1 hit, 3 F (evict 1), 1 F (evict 2), 2 F (evict 3) → 5 faults.
Can you get the rest right without peeking?
Take the timed Quiz: Page Replacement Numericals quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →