What is a Bloom filter, and what kinds of mistakes can it make?
Sketch your own answer first, then compare it with the one below.
A strong answer
A Bloom filter is a bit array with several hash functions. To add a key, you set the bits its hashes point to. To check a key, you test those same bits. If any is zero, the key is definitely absent. If all are set, the key is possibly present.
It makes only one kind of mistake: a false positive, where an absent key happens to land on bits that other keys have set. It never makes a false negative, because a key that was added has all its bits set.
That one-sided error is what makes it useful as a guard in front of an expensive lookup. A false positive costs one wasted lookup, never a wrong answer.
Sources
- Burton H. Bloom (1970). Space/time trade-offs in hash coding with allowable errors.