Predict the output
Five replicas, writes need 3 acks. What is the smallest R that guarantees each read overlaps the last acknowledged write?
N, W = 5, 3
R = next(r for r in range(1, N + 1) if W + r > N)
print(R)Hint 1 of 1
The sets must overlap: W + R > N.
Choose an answer, then open Show answer below to check it.
Show answer
Answer: A 3
Correct. 3 + 3 = 6 > 5, so any 3 read replicas include one of the 3 written.
Every read set of R replicas overlaps the latest write set of W only when R + W > N, which here means R > 2. The smallest whole number that works is 3.
Why not the others?
- B
2. 3 + 2 = 5, not greater than 5: the two sets can miss each other. - C
1. One replica may be one that didn't get the write. - D
5. Works but isn't the smallest.