Sliding window (fixed size)
medium 18 minA fixed sliding window looks at every run of exactly k neighbouring items.
Where it shows up
The same pattern appears across everyday software.
Rate limiting APIs
A limiter that allows 100 requests per trailing 60 seconds keeps the requests inside a window that slides with the clock: new requests enter, old ones fall out, and the count is checked in constant time.
Moving averages on dashboards and charts
A 7-day average of sales, a 50-day average of a stock price or a 5-minute average of CPU load is a fixed window sum divided by k, updated with one add and one drop as each new point arrives.
Audio and signal processing
Audio is cut into overlapping frames of a fixed number of samples, and smoothing filters, loudness meters and short-time Fourier transforms all run over those sliding frames.
Genomics: counting k-mers
DNA tools count every substring of length k (a k-mer) in a genome. Sliding a window one base at a time with a rolling hash or a rolling count avoids re-reading the k bases each time.
Plagiarism and duplicate detection
The Rabin-Karp rolling hash removes the leaving character and adds the entering one, so every window of a document gets a fingerprint in O(1) and matching chunks are found in one pass.
Monitoring peaks over a time window
Alerting on the maximum latency over the last N requests, or the highest temperature in the last hour, is the sliding window maximum, and monotonic deques are how streaming systems keep it cheap.