# Generating Gray Codes in O(1) Worst-Case Time per Word

@inproceedings{Walsh2003GeneratingGC, title={Generating Gray Codes in O(1) Worst-Case Time per Word}, author={Timothy R. S. Walsh}, booktitle={DMTCS}, year={2003} }

We give a definition of Gray code that, unlike the standard "minimal change" definition, is satisfied by the word-lists in the literature called "Gray codes" and we give several examples to illustrate the various concepts of minimality. We show that a non-recursive generation algorithm can be obtained for a word-list such that all the words with the same prefix (or, equivalently, suffix) are consecutive and that the Bitner-Ehrlich-Reingold method of generating each word in a time bounded by a…

## 40 Citations

### ECO-based Gray codes generation for particular classes of words

- Computer Science
- 2012

The techniques presented here are complementary to that of [4]: it is less general but easy to describe, understand, implement and manipulate, and has the advantage that intermediate produced objects are still (smaller size) objects in the same class.

### Flip-swap languages in binary reflected Gray code order

- Computer ScienceTheoretical Computer Science
- 2022

### A loop-free two-close Gray-code algorithm for listing k-ary Dyck words

- Computer ScienceJ. Discrete Algorithms
- 2006

### More restrictive Gray codes for necklaces and Lyndon words

- Computer ScienceInf. Process. Lett.
- 2008

### Inside the Binary Reflected Gray Code: Flip-Swap Languages in 2-Gray Code Order

- Computer ScienceWORDS
- 2021

It is proved that any flip-swap language forms a cyclic 2-Gray code when listed in binary reflected Gray code (BRGC) order and a generic successor rule computes the next string when provided with a membership tester.

### Restricted compositions and permutations: From old to new Gray codes

- MathematicsInf. Process. Lett.
- 2011

### Gray codes and efficient exhaustive generation for several classes of restricted words. (Codes de gray et génération exhaustive pour certaines classes de mots sous contrainte)

- Computer Science
- 2015

The Steinhaus-Johnson-Trotter Gray code for permutations, when restricted by avoiding some set of patterns, still remains a (possibly less restricted) Gray code, and the main ingredients are used in the investigation of the Graycodeness.

### Loop-free Gray code algorithm for the e-restricted growth functions

- Computer ScienceInf. Process. Lett.
- 2011

### Two Reflected Gray Code-Based Orders on Some Restricted Growth Sequences

- MathematicsComput. J.
- 2015

The first suffix partitioned Gray codes for restricted growth f unctions and ascent sequences are given; these latter sequences code various combinatorial classes as interval orders, upper triangular matrices without zero rows and zero columns whose non-negative integer entries sum up to n, and certain pattern-avoiding permutations.

### On the exhaustive generation of generalized ballot sequences in lexicographic and Gray code order

- Computer SciencePure Mathematics and Applications
- 2019

It is shown that the Reected Gray Code order induces a cyclic 3-adjacent Gray code on both, the set of fixed length generalized ballot sequences and p-ary ballot sequences when p is even, that is, ordered list where consecutive sequences differ in at most 3 adjacent positions.

## References

SHOWING 1-10 OF 28 REFERENCES

### Simple Combinatorial Gray Codes Constructed by Reversing Sublists

- Computer ScienceISAAC
- 1993

Three related results about simple combinatorial Gray codes constructed recursively by reversing certain sublists are presented and a new Gray code list of the partitions of a set into a fixed number of blocks is developed.

### A Loopless Gray-Code Algorithm for Listing k-ary Trees

- Computer ScienceJ. Algorithms
- 2000

This paper presents the first loopless algorithm for listing the bit sequence representations of k-ary trees in a Gray-code order and is the only known algorithm that generates the bit sequences by homogeneous transpositions.

### Generation of Well-Formed Parenthesis Strings in Constant Worst-Case Time

- Computer ScienceJ. Algorithms
- 1998

Two nonrecursive versions of the Proskurowski and Ruskey algorithm for generating well-formed parenthesis strings of length 2n are presented, one of which generates each string inO(n) worst-case time and requires space for onlyO(1) extra integer variables.

### Combinatorial Gray codes

- Mathematics, Computer ScienceSIAM J. Comput.
- 1980

“loop-free” or “uniformly bounded transition” algorithms, i.e., algorithms which yield linear orders on the sets C(n,k) so that the vectors representing consecutive objects are “close to each other” (combinatorial Gray codes).

### Efficient generation of the binary reflected gray code and its applications

- Computer ScienceCACM
- 1976

Algorithms to generate the n-bit binary reflected Gray code and codewords of fixed weight in that code are presented and applications to the generation of the combinations of n things taken k at a time, the compositions of integers, and the permutations of a multiset are discussed.

### Generation of permutations by adjacent transposition

- Mathematics
- 1963

1. RICHARD S. VARGA, Matrix Iterative Analysis, Prentice-Hall, Inc., 1962. 2. E. G. D'YAKONOV, "On a Method of Solving the Poisson Equation," Dokl. Akad. Nauk SSSR 143 (1962), 21-24, the same paper…

### Loopless Algorithms for Generating Permutations, Combinations, and Other Combinatorial Configurations

- Computer ScienceJACM
- 1973

The purpose of this work is to find a method for building loopless algorithms for listing combinatorial items, like partitions, permutations, combinations. Gray code, etc. Algorithms for the above…