-   if $\sum_{i=1}^ks_i$ is odd, then $a'\in\{a-1,a,a+1\}$, and so the length of $\tau_{a,b}$ and that of $\tau_{a',b}$ differ by at most one; and

-   if $\sum_{i=1}^ks_i$ is even, then $M'\in\{M-1,M,M+1\}$, and the length of the non-zero tail of ${\boldsymbol{s}}$ and that of ${\boldsymbol{t}}$ (defined by means of $\tau$ sequences) differ by at most two.

Finally, the whole sequences ${\boldsymbol{s}}$ and ${\boldsymbol{t}}$ differ in at most five (not necessarily adjacent) positions, and the statement holds.

Generating algorithms
=====================

An exhaustive generating algorithm is one generating all sequences in a combinatorial class, with some predefined properties ([*e.g.*]{}, having the same length). Such an algorithm is said to run in [*constant amortized time*]{} if it generates each object in $O(1)$ time, in amortized sense. In [@Ruskey] the author called such an algorithm [*CAT algorithm*]{} and shows that a recursive generating algorithm satisfying the following properties is precisely a CAT algorithm:

-   Each recursive call either generates an object or produces at least two recursive calls;

-   The amount of computation in each recursive call is proportional to the degree of the call (that is, to the number of subsequent recursive calls produced by current call).

Procedure [Gen1]{} in Fig. \[fig:alg\_Rnb\_odd\] generates all sequences belonging to $R_n(b)$ in Reflected Gray Code Order. Especially when $b$ is odd, the generation induces a 3-adjacent Gray code. The bound $b$ and the generated sequence $s=s_1s_2\ldots s_n$ are global. The $k$ parameter is the position where the value is to be assigned (see line 8 and 13); the $dir$ parameter represents the direction of sequencing for $s_k$, whether it is up (when $dir$ is even, see line 7) or down (when $dir$ is odd, see line 12); and $m$ is such that $m+1$ is the the maximum value that can be assigned to $s_k$, that
-    if $ \sum_{i=1}^ks_i$ is odd, then $ a'\in\{a-1,a, a+1\}$, and so the length of $ \tau_{a, b}$ and that of $ \tau_{a',b}$ differ by at about one; and 

 -    if $ \sum_{i=1}^ks_i$ is even, then $ M'\in\{M-1,M, M+1\}$, and the duration of the non - zero tail of $ { \boldsymbol{s}}$ and that of $ { \boldsymbol{t}}$ (defined by mean of $ \tau$ sequences) disagree by at most two. 

 Finally, the unharmed sequences $ { \boldsymbol{s}}$ and $ { \boldsymbol{t}}$ differ in at about five (not inevitably adjacent) positions, and the statement hold. 

 Generating algorithms 
 = = = = = = = = = = = = = = = = = = = = = 

 An exhaustive generating algorithm is one render all succession in a combinatorial course, with some predefined properties ([ * for example * ] { }, own the same length). Such an algorithm is said to operate in [ * constant amortized time * ] { } if it generate each object in $ O(1)$ clock time, in amortized sense. In [ @Ruskey ] the author called such an algorithm [ * CAT algorithm * ] { } and shows that a recursive generating algorithm satisfying the follow properties is precisely a CAT algorithm: 

 -    Each recursive call either generates an object or produces at least two recursive margin call; 

 -    The amount of computation in each recursive call is proportional to the degree of the call (that is, to the number of subsequent recursive calls produced by current call). 

 Procedure [ Gen1 ] { } in Fig. \[fig: alg\_Rnb\_odd\ ] generates all sequence belonging to $ R_n(b)$ in Reflected Gray Code Order. Especially when $ b$ is leftover, the coevals induces a 3 - adjacent Gray code. The bound $ b$ and the generated succession $ s = s_1s_2\ldots s_n$ are ball-shaped. The $ k$ parameter is the position where the value is to be assigned (determine line 8 and 13); the $ dir$ parameter represents the direction of sequencing for $ s_k$, whether it is up (when $ dir$ is even, see line 7) or down (when $ dir$ is odd, see line 12); and $ m$ is such that $ m+1 $ is the the maximum value that can be assign to $ s_k$, that
-   lf $\sum_{i=1}^ks_i$ is odd, then $a'\ln\{a-1,a,a+1\}$, and so the length of $\tah_{a,b}$ and ghat of $\tau_{a',b}$ differ by at mlsr one; and

-   if $\sum_{i=1}^ks_i$ is exen, then $L'\in\{M-1,M,M+1\}$, abd tie length of the non-zero tail kn ${\bolbsbmbol{s}}$ and that of ${\boldsykbol{t}}$ (defined ty mzans of $\tau$ sequences) differ by at mjst two.

Gijally, the wholg seqlegces ${\boldsymbol{s}}$ and ${\boldsymbol{t}}$ diffed in at most five (noy necessarily adjacent) posltiojs, and the statemejt holds.

Gengdatybg algorithmr
=====================

An exhausuire generatihg algorithm is one generating xll szquences in a coltinatorial rlass, rith some prccefineg propetties ([*e.g.*]{}, havinn the sane length). Such an algmrithm is said to tun in [*convtcnt amortized time*]{} if ir gengratev eazy ocjedt ih $O(1)$ tile, mn amortizes sense. In [@Euskey] the author csljvc such an alforithi [*SAT algorithm*]{} and shows that a recursivt gensrating algorithm satisdying the following ptoperties ys precisely a CAT algorithm:

-   Each recursive caln eitief gtncvater aj object or produces at least two recursive cwmlx;

-   The amount on computation in escj tgcursive call ks pro'krfional to the degrfe of tre caol (that if, to the number of subsequent rwcursive caljw produced by currznt call).

Proczdure [Ben1]{} im Fig. \[fig:alg\_Rnb\_odd\] genexates zll sequencfs belongjvg to $R_n(b)$ in Refuecned Cray Codt Order. Especially when $b$ iw odb, the geverajion inquces a 3-aduacenb Gray code. The boujd $b$ cnd tve generatfd sequence $s=s_1s_2\ldots s_n$ are glouel. The $k$ parakeder is the 'ositipn where the dalue is to be assignzd (see line 8 and 13); the $dmr$ parameter represents tvg direction oh sequencyng dor $w_k$, whetfdr it is up (whrn $dir$ is even, see oine 7) or down (when $dit$ js odd, see line 12); abd $m$ is such thst $o+1$ if nhe tra maximum vanue ghag can ce assigned go $s_l$, that
- if $\sum_{i=1}^ks_i$ is odd, then $a'\in\{a-1,a,a+1\}$, the of $\tau_{a,b}$ that of $\tau_{a',b}$ and if $\sum_{i=1}^ks_i$ is then $M'\in\{M-1,M,M+1\}$, and length of the non-zero tail of and that of ${\boldsymbol{t}}$ (defined by means of $\tau$ sequences) differ by at two. Finally, the whole sequences ${\boldsymbol{s}}$ and ${\boldsymbol{t}}$ differ in at most five necessarily positions, the holds. Generating algorithms ===================== An exhaustive generating algorithm is one generating all sequences in a combinatorial with some predefined properties ([*e.g.*]{}, having the same Such an algorithm is to run in [*constant amortized if generates each in time, amortized sense. In the author called such an algorithm [*CAT algorithm*]{} and shows that a recursive generating algorithm satisfying the properties is CAT algorithm: Each call generates an object at least two recursive calls; - computation in each recursive call is proportional to degree of call (that is, to the number subsequent recursive calls produced by current call). Procedure in Fig. \[fig:alg\_Rnb\_odd\] generates all sequences belonging to $R_n(b)$ in Reflected Gray Code Order. Especially is odd, the generation a 3-adjacent Gray The $b$ the sequence $s=s_1s_2\ldots are global. The $k$ parameter is the position where the value to be assigned (see line 8 and 13); the $dir$ the of sequencing for whether it is up $dir$ even, see line 7) (when is 12); $m$ such that $m+1$ is the maximum value that can assigned to $s_k$, that
-   if $\sum_{i=1}^ks_i$ is odd, then $a'\in\{a-1,a,a+1\}$, aNd so the lenGth of $\Tau_{A,b}$ aNd That Of $\taU_{a',b}$ differ by at mOSt onE; and

-   if $\sum_{i=1}^ks_i$ is even, theN $M'\in\{M-1,m,M+1\}$, ANd thE LeNgth oF the non-ZErO TAil Of ${\BoLdsYmBOl{S}}$ and tHat Of ${\boldsYmbol{t}}$ (defiNed By Means of $\tau$ seQUeNces) differ By aT most two.

FinaLly, The whoLe SeqUEnces ${\BolDsymbOl{s}}$ and ${\BOldsymBol{t}}$ diffeR iN At most FIve (not nECEsSariLy adjacent) positioNS, aND the statement hOlds.

GeNeRAtING alGorIthms
=====================

An exhAuStive GEneratiNG aLGORitHM is one generatIng all sequeNCes In a comBiNatORial clAss, wiTh SOme Predefined pRopeRties ([*e.g.*]{}, haVing thE Same lenGTh). Such aN algorIthM is Said TO rUn In [*cOnSTanT AmOrtIZed Time*]{} if it GeNeRates Each OBJECt in $o(1)$ tiMe, in AmortIzed sense. In [@RuSkeY] the AUthOr calLed suCh an AlGoritHm [*CAT aLgoriThM*]{} and shows that a rEcurSive generAtiNg AlgOrIthm sATisfyiNg tHe fOllowinG properTIes Is PRECiSely a CAT algorithm:

-   EAcH REcUrsive caLl eithER gEnERates an oBjEct Or prODUces aT leaST tWo recursIve calLS;

-   THe Amount oF cOmputaTiOn iN eaCh recURsivE call iS proportIonal TO the degree of thE Call (that is, to tHE nUMBeR Of suBseQuent recursIve cALls pRoduCEd By cURrent Call).

PRoCEdURe [Gen1]{} in Fig. \[fig:alg\_Rnb\_OdD\] generAtes aLl sequences beLonging to $R_N(B)$ IN ReflectEd GrAY CODe Order. EspeciaLly whEn $b$ is odd, thE GeneratiOn indUces a 3-adjAcent Gray CODe. The bouNd $b$ And The GenERAtEd sequence $s=s_1s_2\LDOts s_N$ aRe globaL. ThE $k$ paramEteR is The PosItIon where tHe value iS tO bE aSsIgnEd (see LIne 8 and 13); thE $dIr$ pArAmeTer rePResentS the dIrecTiOn OF seQuencinG FoR $S_K$, wheThEr It is Up (wHeN $dir$ iS eveN, See Line 7) or dOwn (when $diR$ is ODd, seE lInE 12); and $m$ is Such that $m+1$ is thE tHe maximum vAlUe tHat can BE Assigned To $s_k$, that
-   if $\sum_{i=1}^ks_i$ i s odd, the n $a' \in \{a -1 ,a,a +1\} $, and so thel engt h of $\tau_{a,b}$ andthatof $\ta u _{ a',b} $ diffe r  b y atmo st  on e; an d

-  i f $\sum _{i=1}^ks_ i$is  even, then$ M' \in\{M-1,M ,M+ 1\}$, and th e l engthof  th e  non- zer o tai l of $ { \bolds ymbol{s}} $a nd tha t  of ${\ b o ld symb ol{t}}$ (definedb ym eans of $\tau$  seque nc e s) d iff erby at most  t wo.
F inally, th e w hol e  sequences ${ \boldsymbol { s}} $ and${ \bo l dsymbo l{t}} $d iff er in at mo st f ive (notnecess a rily ad j acent)positi ons , a nd t h est ate me n t h o ld s.Gen eratingal go rithm s
== = = = = ==== === ==== ====
An exhaustiv e g ener a tin g alg orith m is  o ne ge nerati ng al lsequences in acomb inatorial  cl as s,wi th so m e pred efi ned  proper ties ([ * e.g .* ] { } ,having the same le ng t h ).  Such an  algor i th mi s said t orun  in[ * const anta mo rtized t ime*]{ }  i fit gene ra tes ea ch  ob jec t in$ O(1) $ time , in amo rtize d  sense. In [@R u skey] the aut h or c al l ed s uch  an algorit hm [ * CATalgo r it hm* ] {} an d sho ws th a t a recursive gener at ing al gorit hm satisfying  the follo w i n g proper ties is precisely a CA T alg orithm:

-   Each r ecurs ive call  either g e n erates a n o bje ctorp r od uces at least t wo r ec ursivecal ls;

-  T heamo unt  o f computa tion inea ch  r ec urs ive c a ll is pr op ort io nal  to t h e degr ee of  the  c al l  (t hat is, to t he n um be r of  su bs equen t re c urs ive cal ls produc edb y cu rr en t call) .

Procedure[G en1]{} inFi g.\[fig: a l g\_Rnb\_ odd\] generates all seq u ences b elo nging  to$R_n(b)$inReflec ted Gray C ode Or der.Es pec i a lly w h e n$b$  i s odd, the g ene ratio nindu ces a 3 -adjacent Gray cod e . T he bound $b$and  the g en era t ed seq ue n ce$ s =s_1s_2\ldots s _n$ are gl ob a l.  The $k$ p a ram et er is t he posi tionw here th e value i s to be a ss igne d (se e line 8 a nd 13);the $dir$ param e te r rep res ents t he  di recti on ofs equ encin g for$s _k$, w hethe rit is up  (when $dir$ is even, s ee lin e 7)ordown (whe n $ d ir$  is odd,seeline 12);and  $m $ issuc h  that  $m+ 1 $ist he th e ma x imum valu e  t hat c an  be assigne d t o $ s_k$,  th a t
- _ if_$\sum_{i=1}^ks_i$ is odd, then_$a'\in\{a-1,a,a+1\}$, and_so_the length_of_$\tau_{a,b}$ and that_of $\tau_{a',b}$ differ_by at most one;_and

-  _if_$\sum_{i=1}^ks_i$ is even, then $M'\in\{M-1,M,M+1\}$, and the length of the non-zero tail of ${\boldsymbol{s}}$_and_that of_${\boldsymbol{t}}$_(defined_by means of $\tau$ sequences)_differ by at most two.

Finally,_the whole_sequences ${\boldsymbol{s}}$ and ${\boldsymbol{t}}$ differ in at most_five_(not necessarily adjacent)_positions, and the statement holds.

Generating algorithms
=====================

An exhaustive generating algorithm_is one generating all sequences in_a combinatorial class,_with_some_predefined properties ([*e.g.*]{}, having_the same length). Such an algorithm_is said to run in [*constant_amortized time*]{} if it generates each object_in $O(1)$ time, in amortized sense._In [@Ruskey] the author called_such an_algorithm [*CAT algorithm*]{} and shows_that a recursive_generating algorithm_satisfying the following_properties is precisely a CAT algorithm:

-_  Each_recursive call either generates an object_or_produces at least_two_recursive_calls;

- _ The amount_of_computation in_each_recursive call is proportional to the_degree_of the call (that is, to the_number of subsequent recursive_calls_produced by current call).

Procedure_[Gen1]{} in Fig. \[fig:alg\_Rnb\_odd\] generates_all sequences belonging to $R_n(b)$ in_Reflected Gray_Code Order._Especially when $b$ is odd, the generation induces a 3-adjacent Gray_code. The bound $b$ and the_generated sequence $s=s_1s_2\ldots s_n$_are global._The_$k$ parameter is_the_position where_the value is to be assigned (see_line 8_and 13); the $dir$ parameter represents_the direction of sequencing_for_$s_k$, whether it is up (when_$dir$ is even, see line 7)_or down (when $dir$ is_odd,_see_line 12); and $m$ is_such that $m+1$ is the the_maximum value that_can be assigned to $s_k$, that