Interview concept

What is a Bloom filter?

A Bloom filter is a space-efficient probabilistic data structure that tests whether an element is in a set. It can return false positives but never false negatives, trading a small error rate for very low memory use.

Interview concept

How it works

How it works

Several hash functions set bits in a bit array, and a lookup checks whether all of those bits are set.

The tradeoff

A reported match may be a false positive, but a miss is always correct, so it never gives false negatives.

When to use it

Use it to skip expensive lookups, as in databases avoiding disk reads for keys that are probably absent.

Interview concept

Responsible use

Use any live AI assistant only where interview, workplace, school, and platform rules allow it. Do not use generated answers to misrepresent your skills, experience, or authorship.

FAQ

Common questions.

Why can a Bloom filter have false positives?

Different elements can set the same bits, so all bits for an absent element may already be set by others.

Where are Bloom filters used?

In databases and caches to avoid expensive lookups for keys that are probably absent.