• Nem Talált Eredményt

2. 29.2 Necessary condition and earlier results

In document Table of Contents (Pldal 185-189)

Since in the period of a perfect array each element is the head of a pattern, the volume of equals the number of the possible patterns. Since each pattern—among others the pattern containing only zeros—can appear only once, any size of is greater then the corresponding size of the window. So we have the following necessary condition due to Cock, further Hurlbert and Isaak: If is an -perfect array, then

and

Different construction algorithms and other results concerning one and two dimensional perfect arrays can be found in the fourth volume of The Art of Computer Programming written by D. E. Knuth [152]. E.g. a (2,1,5,32)-perfect array [152][page 22], a 36-length even sequence whose 4-length and 16-length prefixes are also even sequences [152][page 62], a (2,2,2,4)-perfect array [152][page 38] and a (4,2,2,16)-perfect array [152][page 63].

It is known [42], [152] that in the one-dimensional case the necessary condition (29.3) is sufficient too. There are many construction algorithms, like the ones of Cock [56], Fan, Fan, Ma and Siu [72], Martin [172] or any algorithm for constructing of directed Euler cycles [166].

Chung, Diaconis and Graham [55] posed the problem to give a necessary and sufficient condition of the existence of -perfect arrays.

The conditions (29.3) and (29.4) are sufficient for the existence of (2,2,a,b)-perfect arrays [72] and (n,2,a,b)-perfect arrays [201]. Later Paterson in [202], [203] supplied further sufficient conditions.

Hurlbert and Isaak [119] gave a construction for one- and two-dimensional growing arrays.

3. 29.3 One-dimensional perfect arrays

In the construction of one-dimensional perfect arrays we use the following algorithms.

3.1. 29.3.1 Pseudocode of the algorithm

Quick-Martin

Algorithm Martin generates one-dimensional perfect arrays. Its inputs are the alphabet size and the window size . Its output is an -ary perfect sequence of length . The output begins with zeros and always continues with the maximal permitted element of the alphabet.

A natural implementation of Martin's algorithm can be found in the chapter Complexity of words of this book.

The following effective implementation of Martin is due to M. Horváth and A. Iványi [115].

Quick-Martin( )

The following implementation of Martin algorithm requires even smaller running time than Quick-Martin. Optimal-Martin( )

1 FOR TO 2 3 FOR TO 4 5

6 FOR TO 7 8 9

10 RETURN

The running time of any algorithm which constructs a one-dimensional perfect array is , since the sequence contains elements. The running time of Optimal-Martin is .

3.3. 29.3.3 Pseudocode of the algorithm

Shift

Algorithm Shift proposed by Cock in 1988 [56] is a widely usable algorithm to construct perfect arrays. We use it to transform cellular -perfect arrays into -perfect arrays.

Shift( )

If is even, then this algorithm generates the -length prefix of an even growing sequence [119].

Even( )

29.3-1 Solve the telex problem, that is construct a -perfect array (using ?).

4. 29.4 Two-dimensional perfect arrays

Perfect Arrays

Chung, Diaconis and Graham posed the problem to give a necessary and sufficient condition of the existence of -perfect arrays.

As Fan, Fan and Siu proved in 1985, the conditions (2) and (3) are sufficient for the existence of (2,2,a,b)-perfect arrays. Paterson proved the same in 1994 [201] for -perfect arrays. Later Paterson [202], [203]

supplied further sufficient conditions.

Hurlbert and Isaak in 1993 gave a construction for one and two dimensional growing arrays.

4.1. 29.4.1 Pseudocode of the algorithm

Mesh

Algorithm Cellular is an extension and combination of the known algorithms Shift, Optimal-Martin, Even and Mesh.

Cellular results a cellular perfect array . Its input data are and , its output is an -perfect

array, where and for . Cellular consists of six parts:

1. Calculation (line 1 in the pseudocode): determines the new alphabet size using formula (29.2);

2. Walking (lines 2–3): if , then construction of a perfect symmetric sequence using algorithm Optimal-Martin (walking in a De Bruijn graph);

3. Meshing (lines 4–6): if is even and , then first construct an -ary even perfect sequence using Even, then construct an sized -ary square using meshing function (29.5);

4. Shifting (lines 7–12): if and ( is odd or ), then use Martin once, then use Shift times, receiving a perfect array ;

5. Combination (lines 13–16): if is even and , then construct an even sequence with Even, construct a perfect square by Mesh and finally use of Shift times, results a perfect array .

6. Report (line 17): returns the output .

29.4-1 Construct a -perfect array (a binary double square for window size .

5. 29.5 Three-dimensional perfect arrays

5.1. 29.5.1 Pseudocode of the algorithm

Colour

Colour transforms cellular perfect arrays into larger cellular perfect arrays. Its input data are

• – the number of dimensions;

• – the extension vector having the property .

The output of Colour is

• a -ary cellular perfect array of size .

Colour consists of four steps:

1. Blocking (line 1) arranging: copies (blocks) of a cellular perfect array into a rectangular array of size and indexing the blocks lexicographically (by );

2. Indexing (line 2): the construction of a lexicographic indexing scheme containing the elements and having the same structure as the array , then construction of a colouring matrix , transforming the elements of into -ary numbers consisting of digits;

3. Colouring (lines 3-4): colouring into a symmetric perfect array using the colouring array that is adding the -fold of the -th element of to each cell of the -th block in (considering the elements of the cell as lexicographically ordered digits of a number).

4. Report (line 5): returns the output .

The output consists of blocks, blocks consist of cells and cells consists of elements. If is an element of , then the lexicographic index of the block containing is called the blockindex of , the lexicographic index of the cell containing is called the cellindex and the lexicographic index of in the cell is called elementindex. E.g. the element in Table 3 has blockindex 5, cellindex 2 and elementindex 1.

Input parameters are , a cellular -perfect array , the output is a -perfect

array , where .

Colour( )

1 arrange the copies of into an array of size blocks 2 construct a lexicographic indexing scheme containing the elements of

and having the same structure as 3 construct an array transforming the elements of into -ary numbers of digits and multiplying them by 4 produce the output adding the -th element of to each cell of the -th block in for each block of 5 RETURN

5.2. 29.5.2 Pseudocode of the algorithm

Growing

Perfect Arrays

Finally, algorithm Growing generates a prefix of a growing array . Its input data are , the number of required doubly perfect prefixes of the growing array , then and . It consists of the following steps:

1. Initialization (line 01): construction of a cellular perfect array using Cellular;

2. Resizing (lines 02–14): if the result of the initialization is not doubly symmetric, then construction of a symmetric perfect array using Colour, otherwise we take as ;

3. Iteration (lines 15–17): construction of the further prefixes of the growing array repeatedly, using

In document Table of Contents (Pldal 185-189)