Skip to main content
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
h1h2h3111Input: "u…Hash 1 → …Hash 2 → …Hash 3 → …All 1s → …
ROOTInput: "user_42"
3 links
Quick 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 sets k hashed bit positions to 1. Querying checks those k bits: if any bit is 0, the element is 100% definitely absent (zero false negatives).
  • Controlled False Positives: If all k bits are 1, 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 m and k upfront: Overfilling a Bloom filter drives its false-positive rate toward 100%; provision based on expected cardinality n and target error p.

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.