Bloom Filter
Add keys to a bit array with several hash functions. Membership tests are fast, but false positives are possible and deletion is not supported.
Cyan bits are set by at least one key; highlighted bits are checked by the current query. If any queried bit is 0, the key is definitely absent. All bits set means “probably present,” because other keys may have set those bits.
What you are seeing
A Bloom filter is a bit array plus several independent hash functions.
Inserting a key sets every bit at its hash positions. Querying checks whether all those bits are set.
If any bit is 0, the key is definitely absent. If all bits are 1, it is probably present — but not guaranteed.
Why it matters
Bloom filters save memory in databases, caches, spelling correction, and network security by answering “definitely not present” very cheaply.
Complexity & details
Insert/lookup: O(k) for k hash functions. Space: O(m) bits, independent of key length.
Frequently asked questions
Why can’t Bloom filters delete?+
Clearing bits for one key could clear bits shared with other keys, creating false negatives. Counting Bloom filters solve this with counters.
What controls the false-positive rate?+
The number of bits, number of inserted keys, and number of hash functions. More bits per key and an optimal k reduce false positives.