<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Exhaustive generation of positive lattice paths</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Antonio Bernini antonio.bernini@uni .it</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff1">1</xref>
          <xref ref-type="aff" rid="aff2">2</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Dipartimento di Matematica e Informatica \U. Dini", Universita degli Studi di Firenze</institution>
          ,
          <addr-line>Viale G.B. Morgagni 65, 50134 Firenze</addr-line>
          ,
          <country country="IT">Italy</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Elena Barcucci</institution>
        </aff>
        <aff id="aff2">
          <label>2</label>
          <institution>Renzo Pinzani</institution>
        </aff>
      </contrib-group>
      <fpage>79</fpage>
      <lpage>86</lpage>
      <abstract>
        <p>We refer to lattice positive paths as to paths in the discrete plane constituted by di erent kinds of steps (north-east, east and south-east), starting from the origin and never going under the x-axis. They have been deeply studied both from a combinatorial and an algorithmic point of view. We propose some algorithms for the exhaustive generation of positive paths which are pre xes of Dyck, Motzkin and q-coloured Motzkin paths, according to their length. For each kind of path we de ne a recursive version as well an iterative one, specifying which path follows a given one in the lexicographic order. Furthermore we study the complexity of these algorithms by using the relations between the number of paths of given size and the number of north-east steps appearing in the nal rise.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Introduction</title>
      <p>Copyright c by the paper's authors. Copying permitted for private and academic purposes.</p>
      <p>In: L. Ferrari, M. Vamvakari (eds.): Proceedings of the GASCom 2018 Workshop, Athens, Greece, 18{20 June 2018, published at
http://ceur-ws.org</p>
      <p>We can establish a total order among the paths in the same class in a very natural way. If p = p1p2:::pn and
r = r1r2:::rn are two paths we say that p precedes r if there is an index k &gt; 0 such that pi = ri for i = 1; :::; k 1
and the step pk lies under the step rk (for the at steps of di erent colours we can choose an order whatever, so
we have D &lt; F1 &lt; F2 &lt; ::: &lt; Fq &lt; U ). We will de ne some algorithms able to exhaustively generate the paths
having the same length according to the above order.
2</p>
    </sec>
    <sec id="sec-2">
      <title>Dyck pre xes</title>
      <p>Dyck paths have been widely studied, both from a combinatorial and an algorithmic point of view, directly
or in connection with the numerous combinatorial structures in bijection with them and enumerated by Catalan
numbers. Well-formed parenthesis, binary trees, parallelogram polyominoes, triangulations of a polygon, chords
on a circle, pattern avoiding permutations are only a few examples. The book of Stanley [Sta15] presents 214
di erent kinds of objects counted by Catalan numbers and many others enumerated by sequences related to
them. In the literature there exist also many papers dealing with exhaustive generation and Gray codes for
structures enumerated by Catalan numbers (see for instance [BR98, Rus03, RW08, VW06, Wal98]).</p>
      <p>Dyck pre xes correspond to ballot sequences and the number of n-length Dyck pre xes is
(sequence A001405 in [S]). From this we can easily obtain that
and
dn =
n
n
b 2 c
d2n = 2d2n 1</p>
      <p>These relations have a very simple interpretation. Any odd length path has a strictly positive height, so we
can add at its end either a rise or a fall step. As a result from any (2n 1)-length path we obtain two 2n-length
di erent paths. The even length paths include also 0-height paths, that is Dyck paths enumerated by Catalan
numbers (Cn), and only a rise step can be added at the end of these paths. As a results from the 2n-length
paths we obtain 2d2n Cn di erent (2n + 1)-length paths.</p>
      <p>In order to exhaustively generate the n-length paths according to the natural order above de ned, we represent
them by means of n-length words on the alphabet f0; 1g, by associating 1 to each rise step and 0 to each fall
step, and then generate the words in lexicographic order.</p>
      <p>The rst n-length word is f irst(n) = (10) n2 if n is even and f irst(n) = (10)b n2 c1 if n is odd. The last one
is always 1n. Furthermore we de ne f irst(n) = " when n 0. We denote by h(w) the di erence between the
number of 1's and the number of 0's in the word w, that is the height of the corresponding path. Let w = v0,
then the following word w0 is v1 and h(w0) = h(w) + 2. If w = v01p then w0 = v10kz where k is the maximum
number of 0's that can be added after v1, that is k = minfp; h(w) p + 2g because h(v1) = h(w) p + 2, and
z = f irst(p k). Furthermore, h(w0) = h(w) 2p + 2 if p &lt; h(w) p + 2 and h(w0) = h(z) otherwise.</p>
      <p>As a result, in order to obtain the successor of a word w it is necessary to scan w from right to left till
the rightmost 0 is detected and then modify w from this position to the end as described above. This can be
achieved by the procedure next() (described in Algorithm 1 in a Java style). We suppose that a is a global array
containing w in the entries 1::n, a[0] = 0 is a ag for recognizing the last word, h is a global variable containing
the height of the path represented in a and f inish a global boolean variable whose value becomes true when the
procedure recognizes the last sequence. After initializing a with f irst(n), h with h(f irst(n)) and f inish with
f alse, the procedure is used into a do-while cycle which stops when f inish becomes true.</p>
      <p>In order to evaluate the complexity of the algorithm it is easy to see that the number of elements tested and
modi ed for generating the next sequence from w = v01p is equal to p + 1. Let tn be the total number of nal
1's in all the n-length words (that is the number of 1's which take part in the 1p su xes). The following relation
Algorithm 1 procedure next for Dyck pre xes
void n e x t ( ) f
i n t j , p=0;
while ( a [ n p]==1) p=p+1;
i f ( p==n ) f i n i s h=true ;
e l s e f
a [ n p ] = 1 ;
h=h p+2;
j=n p+1;
while ( h&gt;0 &amp;&amp; j&lt;=n ) f a [ j ] = 0 ; j=j +1; h=h 1;g
while ( j &lt;n ) f a [ j ] = 1 ; a [ j +1]=0; j=j +2;g
i f ( j==n ) f a [ n ] = 1 ; h=h+1;g
g
holds tn = tn 1 + dn 1 because an element 1 can be added at the end of any (n 1)-length word and the nal
1's are still nal 1's. So the total number of operations necessary to generate all the n-length words is tn + dn
and the average number for each word is
avgn = tn + dn = tn + 1</p>
      <p>dn dn
So the quantity rn = dtnn must be evaluated.</p>
      <p>r2n =
t2n = t2n 1 + d2n 1 = 1
d2n 2d2n 1 2</p>
      <p>(r2n 1 + 1)
r2n+1 = t2n+1 = t22nnn+++11 dd22nn = t2n 1 + d2n 1 + 2d2n 1 =
d2n+1 2 2nn++11 d2n 1</p>
      <p>n + 1
2(2n + 1)
(r2n 1 + 3)</p>
      <p>If r2n 1 &lt; 2 then
for n &gt; 1.</p>
      <p>n + 1
r2n+1 &lt; 2(2n + 1)
5 =
5n + 5
4n + 2
&lt; 2
Since r1 &lt; 2 we can conclude that rn &lt; 2 for n 1 and avgn &lt; 3, so the algorithm has the CAT property.</p>
      <p>A recursive version can also be de ned. The array a and h have the same meaning and do not necessitate
any initialization. The array a is lled from left to right: the rst parameter of the procedure dyckR is the next
position j to be de ned and the second parameter indicates the height of the Dyck pre x represented in the rst
j 1 entries of a. If the value of the rst parameter in a call is greater than n, a new pre x is contained in a
and it can be displayed (or elaborated). Otherwise the pre x is not yet completed: a fall step is added (a[j] = 0)
and a recursive call with parameters j + 1 and h 1 is generated only if h &gt; 0, while a rise step can always be
added (a[j] = 1) followed by a recursive call with parameters j + 1 and h + 1. The initial call is dyckR(1; 0).</p>
      <p>In order to evaluate the complexity we can consider the total number of recursive calls made for generating
all the n-length words, because any call makes a constant number of operations. We can slightly modify the
procedure in such a way that any call outputs a new word or generate exactly two recursive calls. In this way
the recursion tree is a binary tree with dn leafs and dn 1 internal nodes and, as a result, we have that the
average number of calls for a word is less than 2 and the algorithm is CAT. When we add a fall step, the height
of the pre x decreases by 1. So if the height was 1 it becomes 0 and at a successive call only a rise step can be
added. So when the height is equal to 1 and we add a fall step in position j, if j &lt; n, we add also a rise step
in position j + 1 and make a call with parameters j + 2 and 1. As a result, the only calls with h = 0 are those
with j = n and in the recursion tree any internal node has exactly two sons. In this case the initial call should
Algorithm 2 recursive procedure for Dyck pre xes
void dyckR ( i n t j , i n t h ) f
i f ( j &gt;n ) f p r i n t ( a ) ; g
e l s e f
i f ( h&gt;0) f a [ j ] = 0 ; dyckR ( j +1 , h 1);g
a [ j ] = 1 ; dyckR ( j +1 , h +1);
Algorithm 3 improved recursive procedure for Dyck pre xes
void dyckRC ( i n t j , i n t h ) f
i f ( j &gt;n ) f p r i n t ( a ) ; g
e l s e f
a [ j ] = 0 ;
i f ( h==1 &amp;&amp; j &lt;n ) f a [ j +1]=1; dyckRC ( j +2 , 1 ) ; g
e l s e dyckRC ( j +1 , h 1);
a [ j ] = 1 ; dyckRC ( j +1 , h +1);
be dyckRC(2; 1), after initializing a[1] = 1.
3</p>
    </sec>
    <sec id="sec-3">
      <title>Motzkin pre xes</title>
      <p>Motzkin numbers [Aig98, DS77] enumerate many combinatorial structures which are very close to those
enumerated by Catalan numbers [Sta15]. Motzkin pre xes have been deeply studied mainly due to their relation
with directed animals and percolation [BPS94, GV88]. They are enumerated by sequence A005773 in [S]. There
is no closed formula for the number mn of n-length Motzkin pre xes, but for our sakes the recurrence relation
(18) [BPS91]:
with the conditions m0 = 1 and m1 = 2, is su cient to state that
mn = 2mn 1 + 3
n 1
n + 1</p>
      <p>mn 2;
mn &gt; 2mn 1:</p>
      <p>In order to exhaustively generate the n-length Motzkin pre xes we represent them by means of n-length words
on the alphabet f0; 1; 2g, by associating 2 to each rise step, 1 to each at step and 0 to each fall step. In this way
the natural order for the paths de ned in the introduction corresponds to the lexicographic order on the words.</p>
      <p>The rst n-length word is 1n and the last one is 2n. We denote by h(w) the height of the path coded by w,
that is the di erence between the number of 2's and the number of 0's in the word w.</p>
      <p>Let w = v0 (w = v1), then the following word w0 is v1 (w0 = v2) and h(w0) = h(w) + 1. If w = v02p then
w0 = v10k1p k where k is the maximum number of 0's that can be added after v1, that is k = minfp; h(w) p+1g
because h(v1) = h(w) p + 1. Furthermore, h(w0) = h(w) p + 1 k. In an analogous way, if w = v12p then
w0 = v20k1p k where k is the maximum number of 0's that can be added after v2, that is k = minfp; h(w) p+1g
because h(v2) = h(w) p + 1. In this case too, h(w0) = h(w) p + 1 k.</p>
      <p>As a result, it is necessary to scan a word w from right to left till the rightmost element di erent from
2 is detected and then modify w from this position to the end as described above, in order to obtain its
successor. This can be achieved by the procedure next() (described in Algorithm 4 in a Java style). We suppose
that a is a global array containing w in the entries 1::n, a[0] = 0 is useful for recognizing the last word, h
is a global variable containing the height of the path represented in a and f inish a global boolean variable
whose value becomes true when the procedure recognizes the last sequence. After initializing a with 1n, h
with 0 and f inish with f alse, the procedure is used into a do-while cycle which stops when f inish becomes true.
Algorithm 4 procedure next for Motzkin pre xes
void n e x t ( ) f
i n t j , p=0;
while ( a [ n p]==2) p=p+1;
i f ( p==n ) f i n i s h =true ;
e l s e f
a [ n p]= a [ n p ] + 1 ;
h=h p+1;
j=n p+1;
while ( h&gt;0 &amp;&amp; j&lt;=n ) f a [ j ] = 0 ; h=h 1; j=j +1;g
while ( j&lt;=n ) f a [ j ] = 1 ; j=j +1;g
g
g</p>
      <p>In order to evaluate the complexity of the algorithm we remark that the number of elements tested and
modi ed for generating the next sequence from w = v02p or w = v12p is equal to p + 1. Let tn be the total
number of nal 2's in all the n-length words (that is the number of 2's which take part in the 2p su xes). The
following relation holds tn = tn 1 + mn 1 because an element 2 can be added at the end of any (n 1)-length
word and the nal 2's are still nal 2's. So the total number of operations necessary to generate all the n-length
words is tn + mn and the average number for each word is</p>
      <p>It is easy to verify that tn &lt; mn. This is true for n = 1, and if we assume that tk &lt; mk for k
obtain
n
1, we
avgn =
tn + mn</p>
      <p>mn
tn = tn 1 + mn 1 &lt; 2mn 1 &lt; mn:
avgn = tn + mn &lt;
mn
mn + mn = 2:
mn
As a result
So this algorithm too has the CAT property.</p>
      <p>A recursive version can be de ned in this case too. The array a and h have the same meaning and do not
necessitate any initialization. The array a is lled from left to right: the rst parameter of the procedure
motzR is the next position j to be de ned and the second parameter indicates the height of the Motzkin pre x
represented in the rst j 1 entries of a. If the value of the rst parameter in a call is greater than n, a new
pre x is contained in a and it can be displayed (or elaborated). Otherwise the pre x is not yet completed: a fall
step is added (a[j] = 0) and a recursive call with parameters j + 1 and h 1 is generated only if h &gt; 0, while a
at and a rise step can always be added (a[j] = 1 and a[j] = 2) followed by a recursive call with parameters j + 1
and h for the at step and parameters j +1 and h+1 for the rise step, respectively. The initial call is motzR(1; 0).</p>
      <p>In order to evaluate the complexity we can consider the total number of recursive calls made for generating all
the n-length words, because any call makes a constant number of operations. We remark that any call outputs
a new word or generate at least two recursive calls. The recursion tree is a tree with mn leafs and a number of
internal nodes less than mn 1 and, as a result, the average number of calls for a word is less than 2 and the
algorithm is CAT.
Algorithm 5 recursive procedure for Motzkin pre xes</p>
    </sec>
    <sec id="sec-4">
      <title>4 q-coloured Motzkin pre xes</title>
      <p>q-coloured Motzkin paths [BDPP95] are a natural generalization of Motzkin paths obtained by allowing q
di erent colours be used for at steps. When q = 2, bicoloured Motzkin paths are enumerated by Catalan
numbers, while their pre xes are counted by the binomial coe cients dn = 2n+1 (sequence A001700 in [S]).
n+1</p>
      <p>The discussion relative to Motzkin pre xes can be easily extended to the pre xes of q-coloured Motzkin paths.
They can be represented by words on the alphabet q = f0; 1; :::; q; q + 1g where q + 1 corresponds to a rise step,
0 to a fall step and 1, 2 ,..., q to the di erent at steps. The rst n-length word is 1n and the last one (q + 1)n.
If w = vx(q + 1)p, where x 2 q and x &lt; q + 1, then the successive word is w0 = vx00k1p k, where x0 = x + 1
and k is the maximum number of 0's that can be added after vx0. We have that h(vx0) = h(vx) = h(w) p if
0 &lt; x &lt; q + 1, because we only change the colour of a at step, and h(vx0) = h(vx) + 1 = h(w) p + 1 otherwise,
because we transform a fall step in a at step or a at step in a rise step. As a result, k = minfp; h(vx0)g.</p>
      <p>In order to obtain w0 it is again necessary to scan w from right to left till the rightmost element di erent
from q + 1 is detected and then modify w starting from this position as described above. This is achieved by
the procedure next() (Algorithm 6). The variables, their meaning and initialization and the use context of the
procedure are the same as for Motzkin pre xes.</p>
      <p>Algorithm 6 procedure next for q-coloured Motzkin pre xes
void n e x t ( ) f
i n t j , p=0;
while ( a [ n p]==q+1) p=p+1;
i f ( p==n ) f i n i s h=true ;
e l s e f
a [ n p]= a [ n p ] + 1 ;
h=h p ;
i f ( a [ n p ] = = 1 j j a [ n p]==q+1) h=h+1;
j=n p+1;
while ( h&gt;0 &amp;&amp; j&lt;=n ) f a [ j ] = 0 ; h=h 1; j=j +1;g
while ( j&lt;=n ) f a [ j ] = 1 ; j=j +1;g
g
g</p>
      <p>As far as the complexity of the algorithm is concerned, we remark that the number of elements tested and
modi ed for generating the next sequence from w = vx2p, where x &lt; q + 1, is equal to p + 1. Let cn;q be the
number of n-length q-coloured Motzkin pre xes. We have that cn;q &gt; (q + 1) cn 1;q because a rise or any at
step can always be added to an (n 1)-length q-coloured pre x.</p>
      <p>The total number tn;q of nal (q +1)'s in all the n-length words again satis es the relation tn;q = tn 1;q +cn 1;q
because an element (q + 1) can be added at the end of any (n 1)-length word and the nal (q + 1)'s are still
nal (q + 1)'s. So the total number of operations necessary to generate all the n-length words is tn;q + cn;q.</p>
      <p>In this case too, we can verify that tn;q &lt; cn;q. This is true for n = 1, as a matter of fact t1;q = 1 and
c1;q = q + 1. By assuming that tk;q &lt; ck;q for k n 1, we obtain
tn;q = tn 1;q + cn 1;q &lt; 2cn 1;q &lt; cn;q:
As a result the average number of elements tested and modi ed in to generate each word is
and this algorithm too has the CAT property.</p>
      <p>We can also de ne a recursive procedure with the same parameters used for Motzkin pre xes. This procedure
(Algorithm 7) adds in position j, corresponding to the rst parameter, a fall step (if the height h of the
prex so long de ned is positive), a at step of any colour, and a rise step. Obviously the recursion stops when j &gt; n.
Algorithm 7 recursive procedure for q-coloured Motzkin pre xes
void qmotzR ( i n t j , i n t h ) f
i n t i ;
i f ( j &gt;n ) f p r i n t ( a ) ; g
e l s e f
i f ( h&gt;0) f a [ j ] = 0 ; qmotzR ( j +1 , h 1 ) ; g
f o r ( i =1; i &lt;=q ; i=i +1) f a [ j ]= i ; qmotzR ( j +1 , h ) ; g
a [ j ]=q +1; qmotzR ( j +1 , h + 1 ) ;
g
g</p>
      <p>Any call of such procedure produces a new sequence or generate at least q + 1 recursive calls. As a result this
version too has the CAT property.
5</p>
    </sec>
    <sec id="sec-5">
      <title>Further developments</title>
      <p>Recently binary words avoiding one or more patterns [BMPP12] have been employed in order to construct sets
of words constituting a non-overlapping code [Bla15], in particular Dyck words and Motzkin words were used
in [BPP12] and [BBPPS16]. Their exhaustive generation and Gray code were tackled in [BBPSV14, BBPSV15,
BBPV15, BBPV17]. It would be interesting to establish similar procedures for pre xes of words avoiding those
patterns.</p>
      <p>Acknowledgements</p>
      <p>This work was partially supported by the GNCS 2018 project \Proprieta combinatorie e rilevamento di pattern
in strutture discrete lineari e bidimensionali".
[Aig98] M. Aigner. Motzkin numbers. European Journal of Combinatorics, 19:663-675, 1998.
[AS95] L. Alonso and R. Schott. Random generation of trees - random generators in computer science. Kluwer,
1995.
[BBHT17] A. Bacher, O. Bodini, H.-K. Hwang and T.-H. Tsai. Generating Random Permutations by Coin
Tossing: Classical Algorithms, New Analysis, and Modern Implementation. ACM Transactions on Algorithms,
13:Art. 24, 43 pp., 2017.
[BBJ17] A. Bacher, O. Bodini and A. Jacquot. E cient random sampling of binary and unary-binary trees via
holonomic equations. Theoretical Computer Science, 695:42{53, 2017.
[BBPPS16] E. Barcucci, S. Bilotta, E. Pergola, R. Pinzani and J. Succi. Cross-bi x-free sets generation via</p>
      <p>Motzkin paths. RAIRO - Theoretical Informatics and Applications, 50:81{91, 2016.
[BPS91] E. Barcucci, R. Pinzani and R. Sprugnoli. The Motzkin family. Pure Mathematics and Applications,
2:249{279, 1991.
[S] N. J. A. Sloane. The on-line encyclopedia of integer sequences. At http://oeis.org.
[Sta15] R. P. Stanley. Catalan numbers. Cambridge University Press, 2015.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [BPS94]
          <string-name>
            <given-names>E.</given-names>
            <surname>Barcucci</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Pinzani</surname>
          </string-name>
          and
          <string-name>
            <given-names>R.</given-names>
            <surname>Sprugnoli</surname>
          </string-name>
          .
          <article-title>The random generation of directed animals</article-title>
          .
          <source>Theoretetical Computer Science</source>
          ,
          <volume>127</volume>
          :
          <fpage>333</fpage>
          {
          <fpage>350</fpage>
          ,
          <year>1994</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [BPS95]
          <string-name>
            <given-names>E.</given-names>
            <surname>Barcucci</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Pinzani</surname>
          </string-name>
          and
          <string-name>
            <given-names>R.</given-names>
            <surname>Sprugnoli</surname>
          </string-name>
          .
          <article-title>The random generation of underdiagonal walks</article-title>
          .
          <source>Discrete Mathematics</source>
          ,
          <volume>139</volume>
          :3{
          <fpage>18</fpage>
          ,
          <year>1995</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [BDPP95]
          <string-name>
            <given-names>E.</given-names>
            <surname>Barcucci</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Del Lungo</surname>
          </string-name>
          ,
          <string-name>
            <given-names>E.</given-names>
            <surname>Pergola</surname>
          </string-name>
          and
          <string-name>
            <given-names>R.</given-names>
            <surname>Pinzani</surname>
          </string-name>
          .
          <article-title>A Construction for Enumerating k-coloured Motzkin Paths</article-title>
          .
          <source>Lecture Notes in Computer Science</source>
          ,
          <volume>959</volume>
          :
          <fpage>254</fpage>
          {
          <fpage>263</fpage>
          ,
          <year>1995</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [BBPSV14]
          <string-name>
            <given-names>A.</given-names>
            <surname>Bernini</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Bilotta</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Pinzani</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Sabri</surname>
          </string-name>
          and
          <string-name>
            <given-names>V.</given-names>
            <surname>Vajnovszki</surname>
          </string-name>
          .
          <article-title>Pre x partitioned Gray code for particular cross-bi x-free sets</article-title>
          .
          <source>Cryptography and Communications</source>
          ,
          <volume>6</volume>
          :
          <fpage>359</fpage>
          {
          <fpage>369</fpage>
          ,
          <year>2014</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [BBPSV15]
          <string-name>
            <given-names>A.</given-names>
            <surname>Bernini</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Bilotta</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Pinzani</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Sabri</surname>
          </string-name>
          and
          <string-name>
            <given-names>V.</given-names>
            <surname>Vajnovszki</surname>
          </string-name>
          .
          <article-title>Gray code orders for q-ary words avoiding a given factor</article-title>
          .
          <source>Acta Informatica</source>
          ,
          <volume>52</volume>
          :
          <fpage>573</fpage>
          {
          <fpage>592</fpage>
          ,
          <year>2015</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [BBPV15]
          <string-name>
            <given-names>A.</given-names>
            <surname>Bernini</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Bilotta</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Pinzani</surname>
          </string-name>
          and
          <string-name>
            <given-names>V.</given-names>
            <surname>Vajnovszki</surname>
          </string-name>
          .
          <article-title>A trace partitioned Gray code for q-ary generalized Fibonacci strings</article-title>
          .
          <source>Journal of Discrete Mathematical Sciences and Cryptography</source>
          ,
          <volume>18</volume>
          :
          <fpage>751</fpage>
          {
          <fpage>761</fpage>
          ,
          <year>2015</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [BBPV17]
          <string-name>
            <given-names>A.</given-names>
            <surname>Bernini</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Bilotta</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Pinzani</surname>
          </string-name>
          and
          <string-name>
            <given-names>V.</given-names>
            <surname>Vajnovszki</surname>
          </string-name>
          .
          <article-title>A Gray code for cross-bi x-free sets</article-title>
          .
          <source>Mathematical Structures in Computer Science</source>
          ,
          <volume>27</volume>
          :
          <fpage>184</fpage>
          {
          <fpage>196</fpage>
          ,
          <year>2017</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [BMPP12]
          <string-name>
            <given-names>S.</given-names>
            <surname>Bilotta</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Merlini</surname>
          </string-name>
          ,
          <string-name>
            <given-names>E.</given-names>
            <surname>Pergola</surname>
          </string-name>
          and
          <string-name>
            <given-names>R.</given-names>
            <surname>Pinzani</surname>
          </string-name>
          .
          <article-title>Pattern 1j+10j avoiding binary words</article-title>
          .
          <source>Fundamenta Informaticae</source>
          ,
          <volume>117</volume>
          :
          <fpage>35</fpage>
          {
          <fpage>55</fpage>
          ,
          <year>2012</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [BPP12]
          <string-name>
            <given-names>S.</given-names>
            <surname>Bilotta</surname>
          </string-name>
          ,
          <string-name>
            <given-names>E.</given-names>
            <surname>Pergola</surname>
          </string-name>
          and
          <string-name>
            <given-names>R.</given-names>
            <surname>Pinzani</surname>
          </string-name>
          .
          <article-title>A new approach to cross-bi x-free sets</article-title>
          .
          <source>IEEE Transactions on Information Theory</source>
          ,
          <volume>58</volume>
          :
          <fpage>4058</fpage>
          {
          <fpage>4063</fpage>
          ,
          <year>2012</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [Bla15]
          <string-name>
            <given-names>S.</given-names>
            <surname>Blackburn</surname>
          </string-name>
          .
          <article-title>Non-overlapping codes</article-title>
          .
          <source>IEEE Transactions on Information Theory</source>
          ,
          <volume>61</volume>
          :
          <fpage>4890</fpage>
          {
          <fpage>4894</fpage>
          ,
          <year>2015</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          [BR98]
          <string-name>
            <given-names>B.</given-names>
            <surname>Bultena</surname>
          </string-name>
          and
          <string-name>
            <given-names>F.</given-names>
            <surname>Ruskey</surname>
          </string-name>
          .
          <article-title>An Eades-McKay algorithm for well formed parantheses strings</article-title>
          .
          <source>Information Processing Letters</source>
          ,
          <volume>68</volume>
          :
          <fpage>255</fpage>
          -
          <lpage>259</lpage>
          ,
          <year>1998</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          [DS77]
          <string-name>
            <given-names>R.</given-names>
            <surname>Donaghey</surname>
          </string-name>
          and
          <string-name>
            <given-names>L.</given-names>
            <surname>Shapiro</surname>
          </string-name>
          .
          <article-title>Motzkin numbers</article-title>
          .
          <source>Journal of Combinatorial Theory Series A</source>
          ,
          <volume>23</volume>
          :
          <fpage>291</fpage>
          -
          <lpage>301</lpage>
          ,
          <year>1977</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          [DFLS04]
          <string-name>
            <given-names>P.</given-names>
            <surname>Duchon</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Flajolet</surname>
          </string-name>
          , G. Louchard and
          <string-name>
            <surname>G.</surname>
          </string-name>
          <article-title>Schae er. Boltzmann samplers for the random generation of combinatorial structures</article-title>
          .
          <source>Combinatorics Probability and Computing</source>
          ,
          <volume>13</volume>
          :
          <fpage>577</fpage>
          {
          <fpage>625</fpage>
          ,
          <year>2004</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          [GV88]
          <string-name>
            <given-names>D.</given-names>
            <surname>Gouyou-Beauchamps</surname>
          </string-name>
          and
          <string-name>
            <given-names>G.</given-names>
            <surname>Viennot</surname>
          </string-name>
          .
          <article-title>Equivalence of the two-dimensional directed animal problem to a one-dimensional path problem</article-title>
          .
          <source>Advances in Applied Mathematics</source>
          ,
          <volume>9</volume>
          :
          <fpage>334</fpage>
          {
          <fpage>357</fpage>
          ,
          <year>1988</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref15">
        <mixed-citation>
          [Knu08]
          <string-name>
            <given-names>D. E.</given-names>
            <surname>Knuth</surname>
          </string-name>
          .
          <source>The Art of Computer Programming</source>
          , vol.
          <volume>4</volume>
          .
          <string-name>
            <surname>Addison-Wesley</surname>
          </string-name>
          ,
          <year>2008</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref16">
        <mixed-citation>
          [Rus03]
          <string-name>
            <given-names>F.</given-names>
            <surname>Ruskey</surname>
          </string-name>
          . Combinatorial Generation. At http://www.1stworks.com/ref/RuskeyCombGen.pdf,
          <year>2003</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref17">
        <mixed-citation>
          [RW08]
          <string-name>
            <given-names>F.</given-names>
            <surname>Ruskey</surname>
          </string-name>
          and
          <string-name>
            <given-names>A.</given-names>
            <surname>Williams</surname>
          </string-name>
          .
          <article-title>Generating Balanced Parentheses and Binary Trees by Pre x Shifts</article-title>
          .
          <source>In: Proc. Fourteenth Computing: The Australasian Theory Symposium</source>
          , CRPIT,
          <volume>77</volume>
          :
          <fpage>107</fpage>
          {
          <fpage>115</fpage>
          ,
          <year>2008</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref18">
        <mixed-citation>
          [VW06]
          <string-name>
            <given-names>V.</given-names>
            <surname>Vajnovszki</surname>
          </string-name>
          and
          <string-name>
            <given-names>T.</given-names>
            <surname>Walsh</surname>
          </string-name>
          .
          <article-title>A loop-free two-close algorithm for listing k-ary Dyck words</article-title>
          .
          <source>Journal of Discrete Algorithms</source>
          ,
          <volume>4</volume>
          :
          <fpage>633</fpage>
          {
          <fpage>648</fpage>
          ,
          <year>2006</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref19">
        <mixed-citation>
          [Wal98]
          <string-name>
            <given-names>T.</given-names>
            <surname>Walsh</surname>
          </string-name>
          .
          <article-title>Generation of well-formed parenthesis strings in constant worst-case time</article-title>
          .
          <source>Journal of Algorithms</source>
          ,
          <volume>29</volume>
          :
          <fpage>165</fpage>
          {
          <fpage>173</fpage>
          ,
          <year>1998</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>