Count Sketch
92 words
1 min read
Visual companion
Python
Type and operator map
Python Week 1: the first filter for runtime behavior
View
Revision summary
What this note is really saying
Short form
# Count Sketch ## Algorithm Maintain a $t \times k$ array $C$ of counters and $t$ hash functions $h_j$ mapping items to $[k]$, plus $t$ sign hash functions $g_j$ mapping items to $\{-1, +1\}$. **Update:** For item $i$, $C[j][h_j(i)] += g_j(i)$ for $j = 1, \dots, t$.

Count Sketch
Algorithm
Maintain a t×k array C of counters and t hash functions hj mapping items to [k], plus t sign hash functions gj mapping items to {−1,+1}.
Update: For item i, C[j][hj(i)]+=gj(i) for j=1,…,t.
Query: f^i=medianjC[j][hj(i)]⋅gj(i)
Heavy Hitters
Find items with frequency >ϕn (where n is stream length).
Misra-Gries: O(k) space, guarantees ϕ=1/(k+1).
Count-Min + Heap: Track top items in a min-heap alongside sketch.
Join Discord
PreviousRandomized OptimizationNextSublinear Algorithms