Skip to question
ASIC.FYI
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
ASIC.FYI/Interview questions/Counting Bloom Filter

Q255·Free·Firmware

Counting Bloom Filter

Difficulty
Hard
Topic
Probabilistic Structures
Language
SV
Interview prompt

Question

Create a bounded-memory approximate membership structure that supports insertion, query, and deletion by using small counters instead of single bits.

Starting point

Question code

class CountingBloom #(int M = 1024, int K = 4, int CW = 4);
  void insert(int key);
  bit might_contain(int key);
  void remove(int key);
  void clear();
endclass
Reviewed example

Trace one case

Input
insert(16'hD0A0); insert(16'hD0A0); remove(16'hD0A0); might_contain(16'hD0A0)
Expected output
1 (might be present)

Counters remain nonzero after one of two insertions is removed; unlike a bit-only Bloom filter, this avoids an immediate false negative for the remaining instance.

What to cover

Requirements

  1. Use K independently seeded hash projections into M counters.
  2. A query may return a false positive but must not return a false negative while the API preconditions hold.
  3. Detect counter overflow and underflow; never silently wrap or claim the guarantee after saturation.
  4. State the precondition required for safe deletion.
Exact question handoffPractice Q255

Solve it in the question bank, keep your progress, and reveal the reviewed solution when your access allows.

Open in question bank →
Solution accessA Free account unlocks the complete reviewed solution.
Continue learning

Firmware

  • Probabilistic Structures
  • Bloom filter
  • Hashing
  • Approximation
Firmware interview questions →
Continue practicing

Related questions

Q168 · Data StructuresEstimate stream frequencies with a Count-Min Sketch→Q268 · Performance ControlToken-Bucket Rate-Limit Monitor→Q237 · AlgorithmsDynamic Connectivity with Disjoint Sets→
ASIC.FYI · Learn silicon end to end.info@asic.fyi