Try
↑ ↓ move↵ openesc close

Interview prep / Indexes and filters

Junior · Indexes and filters · System design interview question

How does the number of bits per key change a Bloom filter?

Sketch your own answer first, then compare it with the one below.

A strong answer

More bits per key means fewer collisions, so a lower false positive rate. The rate falls fast at first and then slowly. Each extra bit per key cuts the false positive rate by a similar factor, so going from a few bits to ten buys a lot, and going from ten to twenty buys a small share of the remaining errors for double the memory.

The number of hash functions matters too. Too few makes each test weak. Too many fills the array with set bits. The best count is about 0.69 times the bits per key.

A good answer gives the trade-off as memory against wasted lookups, and ties the choice to how costly a wasted lookup is.

Sources

Learn it by running it

The indexes and bloom filters lesson explains the mechanism behind this question, and its lab lets you change the parameters and watch the effect.

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms