Abstract
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 constant works under the additional condition that in the interval of words with the same prefix or suffix the next letter assumes at least two values. Finally we generalize this method so that it works under a weaker condition satisfied by almost all the Gray codes in the literature: if the next letter assumes only one value, then the interval contains only one word.
This is a preview of subscription content, log in via an institution.
Buying options
Tax calculation will be finalised at checkout
Purchases are for personal use only
Learn about institutional subscriptionsPreview
Unable to display preview. Download preview PDF.
References
Gray, F.: Pulse Code Communication. U.S. Patent 2 632 058 (March 17, 1953)
Liu, C.N., Tang, D.T.: Algorithm 452, Enumerating M out of N objects. Comm. ACM 16 (1973) 485
Eades, P., McKay, B.: An Algorithm for Generating Subsets to Fixed Size with a Strong Minimal Interchange Property. Information Processing Letters 19 (1984) 131–133
Johnson, S.M.: Generation of Permutations by Adjacent Transpositions. Mathematics of Computation 17 (1963) 282–285
Trotter, H.F.: Algorithm 115: Perm. Comm. ACM 5 (1962) 434–435
Nijenhuis, A., Wilf, H.S.: Combinatorial Algorithms for Computers and Calculators, second edition. Academic Press, N.Y. (1978)
Chase, P.J.: Combination Generation and Graylex Ordering. Proceedings of the 18th Manitoba Conference on Numerical Mathematics and Computing, Winnipeg, 1988. Congressus Numerantium 69 (1989) 215–242
Ruskey, F.: Simple Combinatorial Gray Codes Constructed by Reversing Sublists. L.N.C.S. 762 (1993) 201–208
Vajnovszki, V., Walsh, T.R.: A loopless two-close Gray code algorithm for listing k-ary Dyck words. Submitted for publication
Ruskey, F., Proskurowski, A.: Generating Binary Trees by Transpositions. J. Algorithms 11 (1990) 68–84
Bultena, B., Ruskey, F.: An Eades-McKay Algorithm for Well-Formed Parentheses Strings. Inform. Process. Lett. 68 (1998), no. 5, 255–259
Savage, C.: Gray Code Sequences of Partitions. Journal of Algorithms 10 (1989) 577–595
Walsh, T.R.: A Simple Sequencingan d Ranking Method that Works on Almost All Gray Codes. Research Report No. 243, Department of Mathematics and Computer Science, Université du Québec à Montréal (April 1995)
Ehrlich, G.: Loopless Algorithms for Generating Permutations, Combinations, and Other Combinatorial Configurations: J. ACM 20 (1973) 500–513
Bitner, J.R., Ehrlich, G., Reingold, E.M.: Efficient Generation of the Binary Reflected Gray Code and its Applications. Comm. ACM 19 (1976) 517–521
Joichi, J.T., White, D.E., Williamson, S.G.: Combinatorial Gray Codes. SIAM J. Computing 9 (1980) 130–141
Walsh, T.R.: Gray Codes for Involutions. JCMCC 36 (2001) 95–118
Walsh, T.R.: Generation of Well-Formed Parenthesis Strings in Constant Worst-Case Time. J. Algorithms 29 (1998) 165–173
Roelants van Baronaigien, D.: A Loopless Gray-Code Algorithm for Listing k-ary Trees. J. Algorithms 35 (2000), no. 1, 100–107
Williamson, S.G.: Combinatorics for Computer Science. Computer Science Press, Rockville (1985)
Roelants van Baronaigien, D.: Constant Time Generation of Involutions. Congressus Numerantium 90 (1992) 87–96
Vajnovszki, V.: Generating Multiset Permutations. Accepted for publication in Theoretical Computer Science
Klingsberg, P.: A Gray Code for Compositions. Journal of Algorithms 3 (1982) 41–44
Walsh, T.R.: Loop-free sequencing of bounded integer compositions, JCMCC 33 (2000) 323–345
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2003 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Walsh, T. (2003). Generating Gray Codes in O(1) Worst-Case Time per Word. In: Calude, C.S., Dinneen, M.J., Vajnovszki, V. (eds) Discrete Mathematics and Theoretical Computer Science. DMTCS 2003. Lecture Notes in Computer Science, vol 2731. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-45066-1_5
Download citation
DOI: https://doi.org/10.1007/3-540-45066-1_5
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-40505-4
Online ISBN: 978-3-540-45066-5
eBook Packages: Springer Book Archive