Bloom Filter
Space-efficient membership tests with controlled false positives
Hash each item into several bits
Adding an item sets k positions in a bit array. A query checks the same positions. If any bit is zero, the item is definitely absent. If every bit is one, the item may be present because other inserted items could have set the same positions.
Try it
00
01
02
03
04
05
06
07
08
09
010
011
012
013
014
015
Add values such as 3, 7, and 11, then query 2 to observe a possible false positive.
Standard Bloom filters never produce false negatives, but they can produce false positives. The probability depends on the bit-array size, number of hash functions, and number of inserted items. They also do not support ordinary deletion because one bit may belong to many items.
Use a Bloom filter to avoid expensive negative lookups: cache penetration checks, storage-engine filters, web-crawl deduplication, and distributed data placement.