Quiz 2

Count Sketch

92 words
1 min read
Python Week 1: the first filter for runtime behavior
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×kt \times k array CC of counters and tt hash functions hjh_j mapping items to [k][k], plus tt sign hash functions gjg_j mapping items to {1,+1}\{-1, +1\}. Update: For item ii, C[j][hj(i)]+=gj(i)C[j][h_j(i)] += g_j(i) for j=1,,tj = 1, \dots, t. Query: f^i=medianjC[j][hj(i)]gj(i)\hat{f}_i = \text{median}_j C[j][h_j(i)] \cdot g_j(i)

Heavy Hitters

Find items with frequency >ϕn> \phi n (where nn is stream length). Misra-Gries: O(k)O(k) space, guarantees ϕ=1/(k+1)\phi = 1/(k+1). Count-Min + Heap: Track top items in a min-heap alongside sketch. Join Discord PreviousRandomized OptimizationNextSublinear Algorithms
Document outline

Keep your place and jump directly to a heading.

Table of Contents
System Normal // Awaiting Context

Intelligence Hub

Navigate the knowledge graph to generate context. The Hub adapts dynamically to surface backlinks, related notes, and metadata insights.