Command Palette

Search for a command to run...

Hectal
PHASE 11Advanced ~6 min· topic 2 of 5

Topic 11.2

Intermediate Questions

In one line

The maths and engineering follow-ups: sizing formulas, optimal k, double hashing, thread safety, serialisation, counting and scalable filters, and cache penetration.

0/5 · 0%

Think of it like this

The practical part of a driving test. You now have to show that you can actually drive: size a filter, choose k, and explain the moving parts.

Key ideas

  1. 01

    Memorise the key numbers: 9.6 bits per item at 1%, 14.4 at 0.1%, 19.2 at 0.01%; optimal k ≈ 0.693 × bits per item; each extra 4.8 bits per item cuts FPR by 10×.

  2. 02

    Show the formula, then a worked number. Interviewers value both.

Code & diagrams

formulas.txttext
p  ~ (1 - e^(-kn/m))^k
m  = -n ln p / (ln 2)^2        (bits)
k  = (m / n) ln 2              (optimal hash count)
bits per item ~ 1.44 log2(1/p)
Example: n = 10M, p = 1%  ->  m ~ 95.9M bits ~ 12 MB, k = 7

Explain it without notes

01

What is the false positive formula?

02

How do you calculate m?

03

How do you calculate optimal k?

04

Why does using too many hash functions hurt?

05

Why does using too few hash functions hurt?

06

What is double hashing?

07

Why must hashes be deterministic?

08

How do you make a Bloom filter thread-safe?

09

How do you serialise a Bloom filter?

10

What is a counting Bloom filter?

11

What is a scalable Bloom filter?

12

How do Bloom filters help with cache penetration?

13

Why is Bloom-filter-only authorisation dangerous?

Practice

01

Size a filter for 50M items at 0.1% and state m, k and memory.

Trade-offs

  • ↔

    Tighter FPR costs linearly more memory (4.8 bits per item per decade) and more hashes.

Done when you can

  • I can answer all thirteen intermediate questions and do the sizing arithmetic live.