Codacoda
Back to Academy

advanced

Bloom Filter

A Bloom Filter is a space-efficient probabilistic data structure used to test whether an element is a member of a set. It can produce false positives but never false negatives, meaning it may incorrectly say an element exists, but will never miss an element that was actually added. It uses multiple hash functions to set bits in a fixed-size bit array.

Use Cases

  • Web browser safe-browsing URL checks
  • Database query optimization to avoid unnecessary disk reads
  • Spam filtering and duplicate detection in large-scale systems

Complexity Analysis

MetricBestAverageWorst
TimeO(k)O(k)O(k)
SpaceO(m)

Visualization

-
[0]
-
[1]
-
[2]
-
[3]
-
[4]
-
[5]
-
[6]
Speed:1x
Hash table with 7 bucketsStep 1 / 18

Implementation

Output

Click "Run Code" to see output...