This week's book giveaway is in the Java in General forum.
We're giving away four copies of Event Streams in Action and have Alexander Dean & Valentin Crettaz on-line!
See this thread for details.
Win a copy of Event Streams in Action this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Gray codes

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can somebody show me the way how to generate next "n" Gray codes, from the given one ?
 
lowercase baba
Posts: 12753
51
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I assume you mean this???
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm curious what you're using them for. My only exposure was building Karnaugh maps which can be used to reduce a set of predicates to their minimal form, eliminating redundant logic tests. I don't even know if taht makes sense. Here are some class notes from tenty some years ago ...

The numbers in the boxes are the decimal value of a set of bits made up of the predicates. The order is the "Gray Code" which changes by one bit from one box to another in any direction. Note that the top and bottom edges are "adjacent", as are the right and left edges. For example, in the 4-variable map only one bit changes when moving from box 2 to box 0, or from box 2 to box A.

For each combination of predicates, if the result is true shade in the box. Also shade in "don't care" boxes; combinations which cannot happen, or for which the result is ignored.

If there are two adjacent shaded boxes, you can ignore the predicate which changes and test only the predicate(s) which do not. For four adjacent boxes ignore the two predicates which change, and for eight adjacent boxes ignore the three predicates which change.

Create an "if test" for each contiguous group of boxes, and "or" those tests together for the final result.
 
Donatas Latauskas
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!