🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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))
  1. A.A C C
  2. B.B C C
  3. C.B C A
  4. 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 →