101. Gray Code Compression
- Author
-
Tomáš Dvořák, Darko Dimitrov, Riste Škrekovski, and Petr Gregor
- Subjects
Gray code ,Combinatorics ,Discrete mathematics ,symbols.namesake ,Amortized analysis ,Cyclic code ,symbols ,Hypercube ,Binary logarithm ,Hamiltonian path ,Graph ,Data compression ,Mathematics - Abstract
An n-bit (cyclic) Gray code is a (cyclic) sequence of all n-bit strings such that consecutive strings differ in a single bit. We describe an algorithm which for every positive integer n constructs an n-bit cyclic Gray code whose graph of transitions is the d-dimensional hypercube Q d if n = 2 d , or a subgraph of Q d if 2 d ? 1 < n < 2 d . This allows to compress sequences that follow this code so that only ${\it \Theta}(\log\log n)$ bits per n-bit string are needed. The algorithm generates the transitional sequence of the code in a constant amortized time per one transition.