<Tr> <Th> n = 4 </Th> <Td> 0000, 0001 </Td> <Td> 1000, 1100, 0100, 0110, 0010, 0011 </Td> <Td> 1010, 1011, 1001, 1101, 0101, 0111 </Td> <Td> 1110, 1111 </Td> </Tr> <P> These monotonic Gray codes can be efficiently implemented in such a way that each subsequent element can be generated in O (n) time . The algorithm is most easily described using coroutines . </P> <P> Monotonic codes have an interesting connection to the Lovász conjecture, which states that every connected vertex - transitive graph contains a Hamiltonian path . The "middle - level" subgraph Q 2 n + 1 (n) (\ displaystyle Q_ (2n + 1) (n)) is vertex - transitive (that is, its automorphism group is transitive, so that each vertex has the same "local environment" " and cannot be differentiated from the others, since we can relabel the coordinates as well as the binary digits to obtain an automorphism) and the problem of finding a Hamiltonian path in this subgraph is called the "middle - levels problem", which can provide insights into the more general conjecture . The question has been answered affirmatively for n ≤ 15 (\ displaystyle n \ leq 15), and the preceding construction for monotonic codes ensures a Hamiltonian path of length at least 0.839N where N is the number of vertices in the middle - level subgraph . </P> <P> Another type of Gray code, the Beckett--Gray code, is named for Irish playwright Samuel Beckett, who was interested in symmetry . His play "Quad" features four actors and is divided into sixteen time periods . Each period ends with one of the four actors entering or leaving the stage . The play begins with an empty stage, and Beckett wanted each subset of actors to appear on stage exactly once . Clearly the set of actors currently on stage can be represented by a 4 - bit binary Gray code . Beckett, however, placed an additional restriction on the script: he wished the actors to enter and exit so that the actor who had been on stage the longest would always be the one to exit . The actors could then be represented by a first in, first out queue, so that (of the actors onstage) the actor being dequeued is always the one who was enqueued first . Beckett was unable to find a Beckett--Gray code for his play, and indeed, an exhaustive listing of all possible sequences reveals that no such code exists for n = 4 . It is known today that such codes do exist for n = 2, 5, 6, 7, and 8, and do not exist for n = 3 or 4 . An example of an 8 - bit Beckett--Gray code can be found in Donald Knuth's Art of Computer Programming . According to Sawada and Wong, the search space for n = 6 can be explored in 15 hours, and more than 9,500 solutions for the case n = 7 have been found . </P>

How can we use exclusive-or to convert the binary number of into gray code