CT041

Bloom Filter Membership

MediumAcceptance: 0.0%

Implement a probabilistic data structure that supports add(value) and check(value) without resizing the underlying array. The check method may return occasional false positives but should always correctly identify a true element. Implement a Bloom filter. Input: first line array size n and number of hash functions k, second line number of operations m, then m lines each like "add v" or "check v". Output: results of check operations ("true" or "false"), one per line.

Example 1:

Input: 100 2 4 add 3 add 5 check 3 check 99
Output: true false

Example 2:

Input: 1000 3 3 add 42 check 42 check 100
Output: true false

Constraints:

1 <= n <= 10^6 1 <= k <= 5 1 <= m <= 10^4 0 <= v <= 10^9

Tags:

bloom-filter hash-table design probabilistic
Loading...
Test Cases:No test cases
No test cases available.