CSData StructuresDiagramIntermediate
Bloom Filter
KO: 블룸 필터·EN: Bloom Filter·JA: ブルームフィルタ
A space-efficient probabilistic data structure using a bit array and multiple hash functions to guarantee definite non-membership and fast possible-membership checks
Table of Contents
Structure Diagram
Bloom Filter Multi-Hash Bit Array Membership CheckTap a node
ROOTInput: "user_42"
3 linksQuick Answer
What is Bloom Filter?
A space-efficient probabilistic data structure using a bit array and multiple hash functions to guarantee definite non-membership and fast possible-membership checks. It is a core concept in Data Structures within CS.
Core Principles
A Bloom Filter is a space-efficient probabilistic data structure backed by an m-bit array and k hash functions that tests set membership without storing actual keys.
O(k)Insert & Query: Inserting setskhashed bit positions to1. Querying checks thosekbits: if any bit is0, the element is 100% definitely absent (zero false negatives).- Controlled False Positives: If all
kbits are1, the item is probably present—triggering a fallback check to the real store. - Tiny Footprint: Filtering 100M keys at a 1% false-positive rate takes roughly ~120MB instead of gigabytes.
Practical Takeaways
- Stop cache penetration: Place a Bloom filter in front of databases to reject lookups for nonexistent IDs before they hit disk.
- Standard Bloom filters cannot delete: Clearing a bit may break other overlapping keys. Use a Counting Bloom Filter or Cuckoo Filter if deletions are required.
- Size
mandkupfront: Overfilling a Bloom filter drives its false-positive rate toward 100%; provision based on expected cardinalitynand target errorp.
Notable Examples
- LSM-Tree Storage Engines (RocksDB, Cassandra, LevelDB): Skip reading SSTables on disk that definitely do not contain a requested key.
- CDNs & Web Crawlers: Prevent one-hit-wonder cache pollution and deduplicate crawled URLs.
- Safe Browsing & Breached Password Checks: Fast local pre-filtering before querying remote APIs.