Imagine a router logging every packet as a 1 and every idle slot as a 0. Every second it sees millions of bits. A traffic analyst wants to know: how many 1s arrived in the last N slots? That single question hides a fundamental tension.
The naive answer is to keep the last N bits in a circular buffer. If , that is a gigabyte per counter â multiply by millions of routers and the numbers become absurd. So the question sharpens: can we answer approximately using only bits of memory?
The answer is yes, thanks to the DGIM algorithm, published in 2002 by Datar, Gionis, Indyk, and Motwani. It introduced the idea of exponential bucketing: rather than remembering individual bits, it keeps a small set of buckets whose sizes are powers of two, each stamped with the timestamp of its most recent 1. When a new 1 arrives, buckets merge like carries in binary addition, keeping the total count below buckets â and the error below 50%.
This article is about one of the cleanest results in streaming algorithms: solving a hard memory problem with a data structure that fits in a tweet.
Comments
Loading comments...