← Quiz: Consistent Hashing: all 15 questions
Quiz: Consistent Hashing · Question 3 of 15
What does this print? (code)
What does this print?
servers = [(50, "A"), (150, "B"), (250, "C")]
def owner(pos):
for p, name in servers:
if pos <= p:
return name
return servers[0][1]
print(owner(120), owner(250), owner(300))
- A.A C C
- B.B C C
- C.B C A
- D.A B A
Answer & explanation
Correct answer: B C A
120 goes to B at 150, 250 lands exactly on C, and 300 is past the last server so it wraps to A.
Can you get the rest right without peeking?
Take the timed Quiz: Consistent Hashing quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →