A Bloom filter is a probabilistic data structure that uses a bit array and multiple hash functions to test set membership, providing two asymmetric answers: 'definitely no' (never wrong, when any bit is zero) and 'probably yes' (may be wrong, when all bits are one due to hash collisions), with false positive probability approximately 1 - e^(-kn/m)^k, where n is items inserted, m is array size, and k is hash functions.
Deep Dive
Prerequisite Knowledge
- No data available.
Where to go next
- No data available.
Deep Dive
Bloom Filters: Probably Yes, Definitely No
Added:Imagine a structure that, when you ask whether something is in it, can give you two kinds of answers. One is probably yes, and sometimes that answer is a lie.
The other is definitely no, and that one is never a lie. The no is always the truth. The yes might be wrong. What kind of structure answers the world like this? It's called a Bloom filter.
At its heart, it's just a row of bits, all zero to start with. To insert a key, you hash it to one of those bit positions, and flip that bit on. Another key, another bit.
But here's the catch. Two different keys can land in the same slot. Apple hashes to position three. Cherry hashes to position three. Now, we have no way to tell them apart. With a single hash, the collisions overwhelm us.
So, we use K hashes instead of one.
Every key arrives, gets hashed K different ways, and we set every one of those bits to one. Apple sets three bits, banana sets three more, cherry sets three, and some of them overlap with what's already there. That's fine.
The bit array is the filter. The keys themselves, we can throw away.
Now, for the trick.
To check if grape is in the set, we hash grape with the same K functions, and look at those bits.
If any one of them is zero, grape was never inserted, because inserting it would have set that bit. A zero is proof. That's the definitely no.
But if every bit is one, the answer is only probably yes.
Those ones could have come from other keys.
Kiwi was never inserted, yet its three bits might all happen to land on bits set by apple and banana.
The filter is lying.
So, how often does it lie? The false positive probability is roughly 1 - e to the - kn over m all raised to the k. n is the number of items inserted, m is the number of bits in the array, and k is the number of hashes. The error bottoms out when k star equals m over n times the natural log of 2. 10 bits per item, seven hashes, and the filter lies less than 1% of the time.
So, that's the whole idea. A bit array, a handful of hashes, and an answer that can be wrong in one direction, but never the other. Definitely no, because a zero bit can't lie. Probably yes, because the ones might come from anywhere. You trade exactness for bits, and it's why Bloom filters quietly sit inside databases, caches, routers, and blockchains.
Anywhere a fast maybe here, takeaway, check saves you from doing an expensive lookup. And that's basically it. If you found this helpful, hit that like button, subscribe for more, and drop a comment if you have any questions. See you in the next one.
Bye-bye.
Related Videos

TOP 15 Data compression Interview Questions and Answers 2019 Part-2 | Data compression | Wisdom jobs
wisdomjobs
281 views•2019-06-28

CTS 158: 802.11w Management Frame Protection
ClearToSend
4K views•2019-02-04

NDSS 2019 Send Hardest Problems My Way: Probabilistic Path Prioritization for Hybrid Fuzzing
NDSSSymposium
496 views•2019-04-02

How realistic is Cities: Skylines?
CityBeautiful
159K views•2019-02-14

GUIs & TUIs: Choosing a User Interface for Your Python Project | Real Python Podcast
realpython
2K views•2025-04-04

The OSI Model - Explained by Example
hnasr
225K views•2019-05-12

Cloud Computing - Introduction
elithecomputerguy
98K views•2019-10-07

From Traveler's Dilemma to Dynamic Routing | Demystifying Networking
IITBombayJuly
5K views•2019-08-04
Trending

WOW! Judge TURNS THE TABLES on Trump in His OWN $10B LAWSUIT!!!
MeidasTouch
197K views•2026-07-23

Playstation NO DISC/NO BUY Fight Is Over...
DavidJaffeGames
4K views•2026-07-23

Steam and Xbox Just Dropped The Hammer On PlayStation
OhNoItsAlexx
9K views•2026-07-23

Americans Confused in Australia for 17 Minutes Straight
IWrocker
17K views•2026-07-23