---
title: "Space-Efficient Counting - Exploring Morris' Algorithm"
url: https://daily.dev/posts/space-efficient-counting---exploring-morris-algorithm-qsuecw6g5
source_url: https://arpitbhayani.me/blogs/morris-counter
type: article
source: "Arpit Bhayani"
published: 2026-05-31T07:54:45.368Z
updated: 2026-05-31T09:21:53.050Z
tags: ["python"]
reading_time: 7
upvotes: 0
comments: 0
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Space-Efficient Counting - Exploring Morris' Algorithm

**[Arpit Bhayani](https://daily.dev/sources/arpit-bhayani)** · 7 min read · 0 upvotes · 0 comments

## Summary

Morris' Algorithm (1977) is a probabilistic approximate counting technique that uses O(log log n) space to count large numbers of events. Instead of storing the exact count, it stores a logarithmic representation and uses a probability-based increment rule: when a new event arrives, the counter increments with probability inversely proportional to the jump between consecutive representable values. This keeps relative error near-constant regardless of the magnitude of n. On an 8-bit register, ordinary counting caps at 256, but Morris' approach can approximate far larger counts. A Python implementation is referenced on GitHub.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://arpitbhayani.me/blogs/morris-counter>

---

Tags: [#python](https://daily.dev/tags/python)

[View this post on daily.dev](https://daily.dev/posts/space-efficient-counting---exploring-morris-algorithm-qsuecw6g5)
