# Gray Codes Generation Algorithm and Theoretical Evaluation of Random Walks in N-Cubes

^{1}

^{2}

^{*}

## Abstract

**:**

## 1. Introduction

## 2. Gray Codes Generation Algorithms

#### 2.1. Inverting Algorithm

#### 2.2. GC Transformation Principle

- the four vertices must be on the same face of the $\mathrm{N}$-cube, i.e., the differences between the four vertices are contained in only two dimensions of the $\mathrm{N}$-cube
- ${C}_{i}$ and ${C}_{j}$ must be diagonally opposed inside the face and, as a consequence, ${C}_{i-1}$ and ${C}_{j+1}$ are diagonally opposed too (this is equivalent to say that transitions $({C}_{i-1},{C}_{i})$ and $({C}_{j},{C}_{j+1})$ go in the same direction along their dimension)

#### 2.3. Generation Algorithm from a Known GC

`dimOfTransition(x,y)`returns the dimension index corresponding to the transition formed by the two neighbors

`x`and

`y`in the $\mathrm{N}$-cube (complexity $\mathcal{O}\left(1\right)$). Also, function

`bitInversion(x,i)`inverses the bit

`i`of vector

`x`($\mathcal{O}\left(1\right)$). Function

`copyAndInvertSubSeq(C,a,b)`returns a copy of cycle

`C`in which the sub-sequence between indices

`a`and

`b`is inverted ($\mathcal{O}\left(\right)open="("\; close=")">\left|C\right|$). Finally, function

`exclusiveInsert(C,L)`inserts cycle

`C`in list

`L`only if

`C`is not yet in

`L`, and it returns the Boolean

`true`when the insertion is performed and

`false`otherwise ($\mathcal{O}\left(\right)open="("\; close=")">{\mathrm{log}}_{2}\left(\right|L\left|\right)$ thanks to the total order induced by the canonical form).

Algorithm 1: Function generateFrom(C). |

#### 2.4. Transitive Closure Algorithm

`generateFrom()`is the one detailed in Algorithm 1.

Algorithm 2: Transitive closure generation algorithm. |

`while`loop is variable, we can compute the total number of iterations of inner loops on

`i`(line 9) and on

`j`(line 11). This allows us to deduce an upper bound of the global complexity as the other actions performed in the

`while`loop: the initialization of

`nl`, the copy of

`nl`into

`il`and the stopping decision, take either constant or linear times (naive copy of

`il`into

`nl`, but optimization is possible) that are negligible compared to the total cost of the loop on

`i`.

`i`, as the

`il`list stores only the new cycles at each iteration of the closure process, we can deduce that each generated cycle is stored only once in this list, and thus is processed only once by the loop. Thus, the total number of iterations performed by this loop is equal to the total number of generated cycles (denoted by L). Inside this loop, the cost of

`generateFrom`is $N.{4}^{N}$ as seen in the previous sub-section. The number of cycles generated by

`generateFrom`may vary from one cycle

`i`to another. However, an amortized complexity analysis using $\alpha $ as the average number of generations per cycle allows us to deduce that the total number of iterations performed by the inner loop in

`j`is $\alpha .L$. This last loop is dominated by the exclusive insertions in the sorted list

`lst`. Here also, the size of that list increases during the whole process, from 0 to L elements. In order to compute the total cost of the successive calls to

`exclusiveInsert()`, we define S as the sum of contributions of every call with a different size of list

`lst`: $S={\sum}_{i=0}^{L-1}{\mathrm{log}}_{2}\left(i\right)<L.{\mathrm{log}}_{2}\left(L\right)$. As there are $\alpha .L$ iterations instead of only L, this bound must be multiplied by $\alpha $. So, the total cost of loop on

`j`is $\mathcal{O}\left(\right)open="("\; close=")">\alpha .L.{\mathrm{log}}_{2}\left(L\right)$.

`generateFrom()`and of the $\alpha .L$ iterations on

`j`, we obtain a total cost of $\mathcal{O}\left(\right)open="("\; close=")">L.(N.{4}^{N}+\alpha .{\mathrm{log}}_{2}\left(L\right))$ for the loop on

`i`. This is clearly the dominant cost in the

`while`loop, and thus the overall complexity of the transitive closure process. Also, the memory complexity is dominated by the list of generated cycles, leading to $\mathcal{O}\left(\right)open="("\; close=")">L.V$.

## 3. Using Gray Codes in Chaotic PRNGs

Algorithm 3: Chaotic PRNG scheme. |

## 4. Reducing the Mixing Time Upper Bound of Boolean Functions in the N-Cube

#### 4.1. Theoretical Context

- $P(X,X)=\frac{1}{2}+\frac{1}{2N}$,
- $P(X,Y)=\frac{1}{2N}$ if $d(X,Y)=1$ and $Y\ne h\left(X\right)$,
- $P(X,Y)=0$ otherwise.

#### 4.2. A Useful Random Process

- $\mathbb{P}({Z}_{i+1}=0\mid {Z}_{i}=0)=1$,
- $\mathbb{P}({Z}_{i+1}=0\mid {Z}_{i}=1)=\frac{1}{2N}$,
- $\mathbb{P}({Z}_{i+1}=2\mid {Z}_{i}=1)=\frac{1}{N}$,
- $\mathbb{P}({Z}_{i+1}=1\mid {Z}_{i}=1)=1-\frac{3}{2N}$,
- $\mathbb{P}({Z}_{i+1}=N\mid {Z}_{i}=N)=\frac{1}{N}$ and $\mathbb{P}({Z}_{i+1}=N-1\mid {Z}_{i}=N)=1-\frac{1}{N}$,
- for every $k\in \{2,\dots ,N-1\}$, $\mathbb{P}({Z}_{i+1}=k-1\mid {Z}_{i}=k)=\frac{k-1}{N}$ $\begin{array}{cc}\hfill \mathrm{and}& \mathbb{P}({Z}_{i+1}=k+1\mid {Z}_{i}=k)=\frac{1}{N}\hfill \\ \hfill \mathrm{and}& \mathbb{P}({Z}_{i+1}=k\mid {Z}_{i}=k)=1-\frac{k}{N},\hfill \end{array}$

**Proposition**

**1.**

**Proof.**

#### 4.3. A Coupling for the Markov Chain P

- (1)
- If $f\left(X\right)\in H(X,Y)$ and $f\left(Y\right)\in H(X,Y)$, then ${W}_{n}={U}_{n}$. Moreover, if ${U}_{n}\notin H(X,Y)$ then, ${Z}_{n}={V}_{n}$, otherwise ${Z}_{n}=1-{V}_{n}$.
- (2)
- If $f\left(X\right)\in H(X,Y)$ and $f\left(Y\right)\notin H(X,Y)$, then ${W}_{n}={U}_{n}$. Moreover, if ${U}_{n}\notin H(X,Y)$ then, ${Z}_{n}={V}_{n}$, otherwise ${Z}_{n}=1-{V}_{n}$.
- (3)
- If $f\left(X\right)\notin H(X,Y)$ and $f\left(Y\right)\in H(X,Y)$, then ${W}_{n}={U}_{n}$. Moreover, if ${U}_{n}\notin H(X,Y)$ then, ${Z}_{n}={V}_{n}$, otherwise ${Z}_{n}=1-{V}_{n}$.
- (4)
- If $f\left(X\right)\notin H(X,Y)$ and $f\left(Y\right)\notin H(X,Y)$, and $f\left(X\right)\ne f\left(Y\right)$. If ${U}_{n}\notin \{f\left(X\right),f\left(Y\right)\}$, then ${W}_{n}={U}_{n}$. If ${U}_{n}=f\left(X\right)$, then ${W}_{n}=f\left(Y\right)$ and if ${U}_{n}=f\left(Y\right)$, then ${W}_{n}=f\left(X\right)$. Moreover, if ${U}_{n}\notin H(X,Y)$ then, ${Z}_{n}={V}_{n}$, otherwise ${Z}_{n}=1-{V}_{n}$.
- (5)
- If $f\left(X\right)\notin H(X,Y)$ and $f\left(Y\right)\notin H(X,Y)$, and $f\left(X\right)=f\left(Y\right)$, then ${W}_{n}={U}_{n}$. Moreover, if ${U}_{n}\notin H(X,Y)$ then, ${Z}_{n}={V}_{n}$, otherwise ${Z}_{n}=1-{V}_{n}$.

**Proposition**

**2.**

**Proof.**

**Lemma**

**1.**

- If ${d}_{n}\ge 2$, then $\mathbb{P}({d}_{n+1}<{d}_{n})\ge \frac{{d}_{n}-1}{N}$.
- If ${d}_{n}\ge 2$, then $\mathbb{P}({d}_{n+1}>{d}_{n})\le \frac{1}{N}$.
- If ${d}_{n}=1$, then $\mathbb{P}({d}_{n+1}=0)\ge \frac{1}{2N}$.
- If ${d}_{n}=1$, then $\mathbb{P}({d}_{n+1}=2)\le \frac{1}{N}$ and $\mathbb{P}({d}_{n+1}=2)\le \mathbb{P}({d}_{n+1}=0)$.

**Proof.**

- If $f\left(X\right)\in H(X,Y)$ and $f\left(Y\right)\in H(X,Y)$ and $f\left(X\right)\ne f\left(Y\right)$. If ${U}_{n}\notin H(X,Y)$, then ${d}_{n+1}={d}_{n}$. If ${U}_{n}\in H(X,Y)$ and ${U}_{n}\ne f\left(X\right)$ and ${U}_{n}\ne f\left(Y\right)$, then ${d}_{n+1}={d}_{n}-1$. If ${U}_{n}=f\left(X\right)$ or ${U}_{n}=f\left(Y\right)$, then ${d}_{n+1}={d}_{n}$ with probability $\frac{1}{2}$ and ${d}_{n+1}={d}_{n}-1$ with probability $\frac{1}{2}$. It follows that, in this case, the probability that ${d}_{n+1}={d}_{n}+1$ is null. The probability that ${d}_{n+1}={d}_{n}-1$ is $\frac{\left|H\right(X,Y)\setminus \{f\left(X\right),f\left(Y\right)\left\}\right|}{N}+\frac{\left|\right\{f\left(X\right),f\left(Y\right)\left\}\right|}{2N}=\frac{{d}_{n}-1}{N}.$
- If $f\left(X\right)\in H(X,Y)$ and $f\left(Y\right)\in H(X,Y)$ and $f\left(X\right)=f\left(Y\right)$. If ${U}_{n}\notin H(X,Y)$, then ${d}_{n+1}={d}_{n}$. If ${U}_{n}\in H(X,Y)$ and ${U}_{n}\ne f\left(X\right)$, then ${d}_{n+1}={d}_{n}-1$. If ${U}_{n}=f\left(X\right)$, then ${d}_{n+1}={d}_{n}$. The probability that ${d}_{n+1}={d}_{n}-1$ is $\frac{\left|H\right(X,Y)\setminus \{f\left(X\right)\left\}\right|}{N}=\frac{{d}_{n}-1}{N}.$
- If $f\left(X\right)\in H(X,Y)$ and $f\left(Y\right)\notin H(X,Y)$. If ${U}_{n}\notin H(X,Y)$ and ${U}_{n}\ne f\left(Y\right)$, then ${d}_{n+1}={d}_{n}$. If ${U}_{n}\in H(X,Y)$ and ${U}_{n}\ne f\left(X\right)$, then ${d}_{n+1}={d}_{n}-1$. If ${U}_{n}=f\left(X\right)$, then ${d}_{n+1}={d}_{n}$ with probability $\frac{1}{2}$ and ${d}_{n+1}={d}_{n}-1$ with probability $\frac{1}{2}$. If ${U}_{n}=f\left(Y\right)$, then ${d}_{n+1}={d}_{n}+1$ with probability $\frac{1}{2}$ and ${d}_{n+1}={d}_{n}$ with probability $\frac{1}{2}$. It follows that the probability that ${d}_{n+1}={d}_{n}+1$ is $\frac{1}{2N}$, and the probability that ${d}_{n+1}={d}_{n}-1$ is $\frac{\left|H\right(X,Y)\setminus \{f\left(X\right)\left\}\right|}{N}+\frac{\left|\right\{f\left(X\right)\left\}\right|}{2N}\ge \frac{{d}_{n}-1}{N}$.
- If $f\left(X\right)\notin H(X,Y)$ and $f\left(Y\right)\in H(X,Y)$. This is a dual case of the previous one with similar calculus, switching $f\left(X\right)$ and $f\left(Y\right)$.
- If $f\left(X\right)\notin H(X,Y)$ and $f\left(Y\right)\notin H(X,Y)$, and $f\left(X\right)\ne f\left(Y\right)$. If ${U}_{n}\notin H(X,Y)\setminus \{f\left(X\right),f\left(Y\right)\}$, then ${d}_{n+1}={d}_{n}$. If ${U}_{n}\in H(X,Y)$, then ${d}_{n+1}={d}_{n}-1$. If ${U}_{n}=f\left(X\right)$, then ${d}_{n+1}={d}_{n}$ with probability $\frac{1}{2}$ and ${d}_{n+1}={d}_{n}+1$ with probability $\frac{1}{2}$. Similarly, If ${U}_{n}=f\left(Y\right)$, then ${d}_{n+1}={d}_{n}$ with probability $\frac{1}{2}$ and ${d}_{n+1}={d}_{n}+1$ with probability $\frac{1}{2}$. Consequently, the probability that ${d}_{n+1}={d}_{n}+1$ is $\frac{1}{2N}+\frac{1}{2N}=\frac{1}{N}$. Moreover the probability that ${d}_{n+1}={d}_{n}-1$ is $\frac{\left|H\right(X,Y\left)\right|}{N}=\frac{{d}_{n}}{N}\ge \frac{{d}_{n}-1}{N}$.
- If $f\left(X\right)\notin H(X,Y)$ and $f\left(Y\right)\notin H(X,Y)$, and $f\left(X\right)=f\left(Y\right)$. If ${U}_{n}\in H(X,Y)$, then ${d}_{n+1}={d}_{n}-1$. If ${U}_{n}\notin H(X,Y)$, then ${d}_{n+1}={d}_{n}$. It follows that the probability that ${d}_{n+1}={d}_{n}+1$ is null and the probability that ${d}_{n+1}={d}_{n}-1$ id $\frac{\left|H\right(X,Y\left)\right|}{N}=\frac{{d}_{n}}{N}\ge \frac{{d}_{n}-1}{N}.$

- If $f\left(X\right)=f\left(Y\right)$. Since f is induced by an Hamiltonian cycle and $N\ge 2$, we cannot have $H(X,Y)=\left\{f\right(X\left)\right\}$. If ${U}_{n}\notin H(X,Y)$, then ${d}_{n+1}={d}_{n}$. If ${U}_{n}\in H(X,Y)$, ${d}_{n+1}={d}_{n}-1$. Therefore, the probability that ${d}_{n+1}={d}_{n}+1$ is null and the probability that ${d}_{n+1}={d}_{n}-1=0$ is $\frac{1}{N}$.
- If $f\left(X\right)\ne f\left(Y\right)$ and $H(X,Y)=\left\{f\right(X\left)\right\}$. If ${U}_{n}\ne f\left(X\right)$ and ${U}_{n}\ne f\left(Y\right)$, then ${d}_{n+1}={d}_{n}$. If ${U}_{n}=f\left(X\right)$, then ${d}_{n+1}=0$ with probability $\frac{1}{2}$ and ${d}_{n+1}={d}_{n}=1$ with probability $\frac{1}{2}$. If ${U}_{n}=f\left(Y\right)$, then ${d}_{n+1}={d}_{n}+1=2$ with probability $\frac{1}{2}$ and ${d}_{n+1}={d}_{n}=1$ with probability $\frac{1}{2}$. Therefore, the probability that ${d}_{n+1}=2$ is $\frac{1}{2N}$ and the probability that ${d}_{n+1}=0=\frac{1}{2N}$.
- If $f\left(X\right)\ne f\left(Y\right)$ and $H(X,Y)=\left\{f\right(Y\left)\right\}$. It a dual case of the previous one. The probability that ${d}_{n+1}=2$ is $\frac{1}{2N}$ and the probability that ${d}_{n+1}=0=\frac{1}{2N}$.
- If $f\left(X\right)\ne f\left(Y\right)$ and $H(X,Y)\cap \left\{f\right(X),f(Y\left)\right\}=\varnothing $. If ${U}_{n}\ne f\left(X\right)$ and ${U}_{n}\ne f\left(Y\right)$, then ${d}_{n+1}={d}_{n}$. If ${U}_{n}=f\left(X\right)$ (resp. $f\left(Y\right)$), then ${d}_{n+1}={d}_{n}+1=2$ with probability $\frac{1}{2}$ and ${d}_{n+1}={d}_{n}=1$ with probability $\frac{1}{2}$. Therefore, the probability that ${d}_{n+1}=2$ is $\frac{1}{N}$ and the probability that ${d}_{n+1}=0=\frac{1}{N}$.☐

**Proposition**

**3.**

**Proof.**

## 5. Experiments

#### 5.1. Performance of Gray Codes Generation Algorithms

#### 5.2. Statistical Study of the Generation Algorithm

#### 5.3. Discussion over the Mixing Time Distributions in Dimensions 5 and 8

## 6. Conclusions

## Author Contributions

## Acknowledgments

## Conflicts of Interest

## References

- Lovász, L. Random walks on graphs. In Combinatorics, Paul Erdos Is Eighty; János Bolyai Mathematical Society: Budapest, Hungary, 1993; Volume 2, pp. 1–46. [Google Scholar]
- Diaconis, P.; Graham, R.L.; Morrison, J.A. Asymptotic analysis of a random walk on a hypercube with many dimensions. Random Struct. Algorithms
**1990**, 1, 51–72. [Google Scholar] [CrossRef] - Lawler, G.F.; Limic, V. Random Walk: A Modern Introduction; Cambridge University Press: Cambridge, UK, 2010; Volume 123. [Google Scholar]
- Scoppola, B. Exact solution for a class of random walk on the hypercube. J. Stat. Phys.
**2011**, 143, 413–419. [Google Scholar] [CrossRef] - Levin, D.A.; Peres, Y. Markov Chains and Mixing Times; American Mathematical Soc.: Providence, RI, USA, 2017; Volume 107. [Google Scholar]
- Contassot-Vivier, S.; Couchot, J.F.; Guyeux, C.; Héam, P.C. Random Walk in a N-Cube Without Hamiltonian Cycle to Chaotic Pseudorandom Number Generation: Theoretical and Practical Considerations. Int. J. Bifurcation Chaos
**2017**, 27, 18. [Google Scholar] [CrossRef] - Suparta, I.; Zanten, A.V. Totally balanced and exponentially balanced Gray codes. Discrete Anal. Oper. Res.
**2004**, 11, 81–98. (In Russia) [Google Scholar] - Contassot-Vivier, S.; Couchot, J.F. Canonical Form of Gray Codes in N-cubes. In Cellular Automata and Discrete Complex Systems, Proceedings of the 23th International Workshop on Cellular Automata and Discrete Complex Systems (AUTOMATA), Milan, Italy, 7–9 June 2017; Part 2: Regular Papers; Dennunzio, A., Formenti, E., Manzoni, L., Porreca, A.E., Eds.; Springer International Publishing: Milan, Italy, 2017; Volume LNCS-10248, pp. 68–80. [Google Scholar]
- Wild, M. Generating all cycles, chordless cycles, and Hamiltonian cycles with the principle of exclusion. J. Discrete Algorithms
**2008**, 6, 93–102. [Google Scholar] [CrossRef] - Couchot, J.; Héam, P.; Guyeux, C.; Wang, Q.; Bahi, J.M. Pseudorandom Number Generators with Balanced Gray Codes. In Proceedings of the 11th International Conference on Security and Cryptography SECRYPT, Vienna, Austria, 28–30 August 2014; pp. 469–475. [Google Scholar]
- Bakiri, M.; Couchot, J.; Guyeux, C. CIPRNG: A VLSI Family of Chaotic Iterations Post-Processings for F2-Linear Pseudorandom Number Generation Based on Zynq MPSoC. IEEE Trans. Circuits Syst.
**2018**, 65, 1628–1641. [Google Scholar] [CrossRef] - Bahi, J.M.; Couchot, J.F.; Guyeux, C.; Richard, A. On the Link between Strongly Connected Iteration Graphs and Chaotic Boolean Discrete-Time Dynamical Systems. In Fundamentals of Computation Theory; Owe, O., Steffen, M., Telle, J.A., Eds.; Springer Berlin Heidelberg: Berlin, Heidelberg, Germany, 2011; pp. 126–137. [Google Scholar]
- Guyeux, C.; Couturier, R.; Héam, P.; Bahi, J.M. Efficient and cryptographically secure generation of chaotic pseudorandom numbers on GPU. J. Supercomput.
**2015**, 71, 3877–3903. [Google Scholar] [CrossRef] [Green Version] - Bakiri, M.; Couchot, J.; Guyeux, C. FPGA Implementation of F2-Linear Pseudorandom Number Generators based on Zynq MPSoC: A Chaotic Iterations Post Processing Case Study. In Proceedings of the 13th International Joint Conference on e-Business and Telecommunications (ICETE 2016): SECRYPT, Lisbon, Portugal, 26–28 July 2016; Callegari, C., van Sinderen, M., Sarigiannidis, P.G., Samarati, P., Cabello, E., Lorenz, P., Obaidat, M.S., Eds.; SciTePress: Setúbal, Portugal, 2016; Volume 4, pp. 302–309. [Google Scholar]
- Marsaglia, G. DIEHARD: A Battery of Tests of Randomness. Available online: https://tams.informatik.uni-hamburg.de/paper/2001/SA_Witt_Hartmann/cdrom/Internetseiten/stat.fsu.edu/diehard.html.
- L’Ecuyer, P.; Simard, R. TestU01: A C Library for Empirical Testing of Random Number Generators. ACM Trans. Math. Softw.
**2007**, 33, 22. [Google Scholar] - Bakiri, M. Hardware Implementation of Pseudo Random Number Generator Based on Chaotic Iterations. Ph.D Thesis, Université Bourgogne Franch-Comté, Belfort, France, 2018. [Google Scholar]
- L’Ecuyer, P. Handbook of Computational Statistics; Springer-Verlag: Berlin, Germany, 2012; Chapter Random Number Generation; pp. 35–71. [Google Scholar]
- L’Ecuyer, P. History of uniform random number generation. In Proceedings of the WSC 2017-Winter Simulation Conference, Las Vegas, NV, USA, 3–6 December 2017; pp. 202–230. [Google Scholar]
- Robinson, J.P.; Cohn, M. Counting Sequences. IEEE Trans. Comput.
**1981**, 30, 17–23. [Google Scholar] [CrossRef] - Bhat, G.S.; Savage, C.D. Balanced Gray Codes. Electr. J. Comb.
**1996**, 3, 25. [Google Scholar] - Suparta, I.; Zanten, A.V. A construction of Gray codes inducing complete graphs. Discrete Math.
**2008**, 308, 4124–4132. [Google Scholar] [CrossRef] - Bykov, I.S. On locally balanced gray codes. J. Appl. Ind. Math.
**2016**, 10, 78–85. [Google Scholar] [CrossRef] - Conder, M.D.E. Explicit definition of the binary reflected Gray codes. Discrete Math.
**1999**, 195, 245–249. [Google Scholar] [CrossRef] - Bunder, M.W.; Tognetti, K.P.; Wheeler, G.E. On binary reflected Gray codes and functions. Discrete Math.
**2008**, 308, 1690–1700. [Google Scholar] [CrossRef] - Berestycki, N. Mixing Times of Markov Chains: Techniques and Examples. Graduate course at cambridge. University of Cambridge: Cambridge, UK, 2016. Available online: http://www.statslab.cam.ac.uk/ beresty/teach/Mixing/mixing3.pdf.
- Norris, J.R. Markov Chains; Cambridge University Press: Cambridge, UK, 1998; ISBN 9780521633963. [Google Scholar]

**Figure 1.**Transitive exploration of the space of Gray Codes (GCs) from the initial black code. Each dot represents one GC. The color gets lighter at each additional transform.

**Figure 2.**Inversion of sub-sequence $({C}_{i},\dots ,{C}_{j})$ inside a face of the $\mathrm{N}$-cube (dotted square).

**Figure 3.**Inversion of sub-sequence $(11,\dots ,14)$ (dotted line) on face (10, 11, 14, 15) in the 4-cube.

**Figure 4.**Examples of possible and valid parallel transitions in the 4-cube. (

**a**) Possible parallel transitions (blue) for a reference transition (black); (

**b**) Two valid parallel transitions (red) for the reference transition (black) in the blue cycle.

**Figure 6.**Construction of function f in dimension 3. (

**a**) Original 3-cube; (

**b**) A Gray code; (

**c**) Function f.

**Figure 7.**Exec times (s) in function of the number of generated GCs for different dimensions of $\mathrm{N}$-cube.

**Table 1.**Generation times of 100,000 Gray Codes (GCs) in function of the dimension of the $\mathrm{N}$-cube.

dim | 5 | 6 | 7 | 8 | 9 | 10 |

time (s) | 19.61 | 19.93 | 28.17 | 53.60 | 174.43 | 332.29 |

dim | 2 | 3 | 4 | 5 |

nb of isolated GCs | 1 | 1 | 3 | 740 |

total nb of GCs | 1 | 1 | 9 | 237,675 |

ratio of isolated (%) | 100 | 100 | 33.3 | 0.3 |

© 2018 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).

## Share and Cite

**MDPI and ACS Style**

Contassot-Vivier, S.; Couchot, J.-F.; Héam, P.-C.
Gray Codes Generation Algorithm and Theoretical Evaluation of Random Walks in N-Cubes. *Mathematics* **2018**, *6*, 98.
https://doi.org/10.3390/math6060098

**AMA Style**

Contassot-Vivier S, Couchot J-F, Héam P-C.
Gray Codes Generation Algorithm and Theoretical Evaluation of Random Walks in N-Cubes. *Mathematics*. 2018; 6(6):98.
https://doi.org/10.3390/math6060098

**Chicago/Turabian Style**

Contassot-Vivier, Sylvain, Jean-François Couchot, and Pierre-Cyrille Héam.
2018. "Gray Codes Generation Algorithm and Theoretical Evaluation of Random Walks in N-Cubes" *Mathematics* 6, no. 6: 98.
https://doi.org/10.3390/math6060098