Skip to main content

Generating Combinations by Prefix Shifts

  • Conference paper
Computing and Combinatorics (COCOON 2005)

Part of the book series: Lecture Notes in Computer Science ((LNTCS,volume 3595))

Included in the following conference series:

Abstract

We present a new Gray code for combinations that is practical and elegant. We represent combinations as bitstrings with s 0’s and t 1’s, and generate them with a remarkably simple rule: Identify the shortest prefix ending in 010 or 011 (or the entire bitstring if no such prefix exists) and then rotate (shift) it by one position to the right. Since the rotated portion of the string consists of at most four contiguous runs of 0’s and 1’s, each successive combination can be generated by transposing only one or two pairs of bits. This leads to a very efficient loopless implementation. The Gray code also has a simple and efficient ranking algorithm that closely resembles that of combinations in colex order. For this reason, we have given a nickname to our order: cool-lex!

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 84.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 109.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Corbett, P.F.: Rotator Graphs: An Efficient Topology for Point-to-Point Multiprocessor Networks. IEEE Transactions on Parallel and Distributed Systems 3, 622–626 (1992)

    Article  Google Scholar 

  2. Chase, P.J.: Combination Generation and Graylex Ordering. Congressus Numerantium 69, 215–242 (1989)

    MathSciNet  Google Scholar 

  3. Diaconis, P., Holmes, S.: Gray codes for randomization procedures. Statistical Computing 4, 207–302 (1994)

    Article  Google Scholar 

  4. Eades, P., Hickey, M., Read, R.: Some Hamilton Paths and a Minimal Change Algorithm. Journal of the ACM 31, 19–29 (1984)

    Article  MathSciNet  MATH  Google Scholar 

  5. Eades, P., McKay, B.: An Algorithm for Generating Subsets of Fixed Size with a Strong Minimal Change Property. Information Processing Letters 19, 131–133 (1984)

    Article  MathSciNet  MATH  Google Scholar 

  6. Ehrlich, G.: Loopless Algorithms for Generating Permutations, Combinations and Other Combinatorial Configurations. Journal of the ACM 20, 500–513 (1973)

    Article  MathSciNet  MATH  Google Scholar 

  7. Jiang, M., Ruskey, F.: Determining the Hamilton-connectedness of certain vertex-transitive graphs. Discrete Mathematics 133, 159–170 (1994)

    Article  MathSciNet  MATH  Google Scholar 

  8. Knuth, D.E.: The Art of Computer Programming, pre-fascicle 4A (a draft of Section 7.2.1.3: Generating all Combinations), p. 61. Addison-Wesley, Reading (2004), http://www-cs-faculty.stanford.edu/~knuth/fasc3a.ps.gz

    Google Scholar 

  9. Ruskey, F.: Simple combinatorial Gray codes constructed by reversing sublists. In: Ng, K.W., Balasubramanian, N.V., Raghavan, P., Chin, F.Y.L. (eds.) ISAAC 1993. LNCS, vol. 762, pp. 201–208. Springer, Heidelberg (1993)

    Chapter  Google Scholar 

  10. Tang, D.T.: C.N. Liu Distance-2 Cycle Chaining of Constant Weight Codes. IEEE Transactions C-22, 176–180 (1973)

    Google Scholar 

  11. Stanton, D., White, D.: Constructive Combinatorics. Springer, Heidelberg (1986)

    Book  MATH  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2005 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Ruskey, F., Williams, A. (2005). Generating Combinations by Prefix Shifts. In: Wang, L. (eds) Computing and Combinatorics. COCOON 2005. Lecture Notes in Computer Science, vol 3595. Springer, Berlin, Heidelberg. https://doi.org/10.1007/11533719_58

Download citation

  • DOI: https://doi.org/10.1007/11533719_58

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-28061-3

  • Online ISBN: 978-3-540-31806-4

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics