Intermediate Topic 33 of 52 Data Structures
Bloom Filters
Probabilistic set membership structure allowing false positives only.
How it works
A Bloom filter sets k bits chosen by k hash functions for each inserted item in a bit array. A query checks whether all k bits are set: if any is zero, the item is definitely absent; if all are one, it is probably present. It can give false positives but never false negatives, uses very little memory and cannot delete items in its basic form.
Where it is used
Avoiding expensive disk or network lookups in databases like Cassandra and HBase, web crawlers remembering visited URLs, malicious-URL checks in browsers and caches use Bloom filters.
Common pitfall
The false-positive rate grows as the filter fills, so size it for the expected item count. Plain filters do not support deletion; use counting Bloom filters if needed. Hash functions must be independent and well distributed. Never treat a positive answer as certain.
Where it fits in the course
Bloom Filters is topic 33 of 52 in Data Structures, rated Intermediate. It follows Skip Lists. The next topic is Splay Trees.
Practice and explore
- Open the interactive lesson, with a mini quiz.
- Take the Data Structures quiz.
- Explore the Hash Table visualizer: Hash function, buckets and chaining collisions.
How to study this topic
- Read the explanation above and restate the definition in your own words.
- Open the interactive lesson and answer its mini quiz.
- Read the common pitfall, then write a short example that avoids it.
- Check your understanding in the Data Structures quiz, and revisit the topic if you miss a question.
Frequently asked questions
What is Bloom Filters?
Where do people use Bloom Filters?
What is the most common mistake with Bloom Filters?
What should I learn before this topic?
How can I practice it?
Is Bloom Filters hard to learn?
How long does it take to learn Bloom Filters?
Which topics are related to Bloom Filters?
What should I study after Bloom Filters?
Related topics
- Skip Lists (Data Structures)
- Splay Trees (Data Structures)
- Path Compression (Data Structures)
- Treaps (Data Structures)