← chapter

Bloom filters

Approximate set membership in a few bits per item. False positives, but NEVER false negatives.

Bit array + k hashes

Watch add & query

Add cat/dog/fox → bits light up. Query cat → all set → yes. 'hycr' never added, but its 3 bits are all set → FALSE POSITIVE.

A hundredfold less memory

1M keys at 1% FPR: Bloom 1.2 MB, set 122 MB → 100× smaller (9.6 bits/item, k=7).

The design formula

Takeaway

Exactness is a resource you can spend — trade a little error for lots of space. The founding idea of probabilistic structures (HyperLogLog, count-min sketch). Next: skip lists — balanced-tree performance from coin flips.