A Bloom filter answers "have I seen this?" A Count-Min sketch answers "how many times?" It is a two-dimensional grid of counters with one hash per row. Today you build the grid and its per-row indexing.
Build a d-by-w counter grid and compute the column index each item maps to in every row.
A Count-Min sketch estimates frequencies - how often each item appeared in a stream - in fixed space, the way a Bloom filter estimates membership. Its shape is a grid of counters, d rows deep and w columns wide, with an independent hash per row. Each item lands on exactly one column in every row, so a single item touches d counters, one per row.
Those per-row columns are nothing new: the i-th column is (h1 + i * h2) mod w, which is precisely the double-hashing Indexes function from the first chapter with k = d and m = w. Reusing it means each row’s hash is independent of the others, which is what makes the estimate work. Today only builds the grid and the indexing; adding and estimating come next.
type CountMin struct {grid [][]uint64d, w int}func NewCountMin(d, w int) *CountMin { /* allocate d rows of w counters */ }// one column per row is exactly Indexes(data, d, w): (h1 + r*h2) mod wfunc (c *CountMin) columns(data []byte) []int { return Indexes(data, c.d, c.w) }