DeBruijn - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.
Our website is currently undergoing maintenance, which may result in occasional errors while browsing. We apologize for any inconvenience this may cause and are working swiftly to restore full functionality. Thank you for your patience.

Online Help

All Products    Maple    MapleSim


Iterator

  

DeBruijn

  

generate Lyndon words that form a de Bruijn sequence

 

Calling Sequence

Parameters

Options

Description

Examples

References

Compatibility

Calling Sequence

DeBruijn(n, m, opts)

Parameters

n

-

nonnegint; maximum length of string

m

-

nonnegint; size of alphabet

opts

-

(optional) equation(s) of the form option = value; specify options for the DeBruijn command

Options

• 

compile = truefalse

  

True means compile the iterator. The default is true.

Description

• 

The DeBruijn command returns an iterator that generates m-ary Lyndon words, each with 0<lengthn, that together form a de Bruijn sequence.

• 

A de Bruijn sequence is a sequence of the characters 0 to m1, of length mn, that, when considered as a cycle, contains each string of length n exactly once.

Methods

In addition to the common iterator methods, this iterator object has the following methods. The self parameter is the iterator object.

• 

Number(self): return the number of iterations required to step through the iterator, assuming it started at rank one.

Examples

withIterator&colon;

Create an iterator that generates Lyndon words with maximum length 4 in an alphabet of 3 characters.

PDeBruijn4&comma;3&colon;

PrintP&comma;showrank&colon;

 1: 0
 2: 0 0 0 1
 3: 0 0 0 2
 4: 0 0 1 1
 5: 0 0 1 2
 6: 0 0 2 1
 7: 0 0 2 2
 8: 0 1
 9: 0 1 0 2
10: 0 1 1 1
11: 0 1 1 2
12: 0 1 2 1
13: 0 1 2 2
14: 0 2
15: 0 2 1 1
16: 0 2 1 2
17: 0 2 2 1
18: 0 2 2 2
19: 1
20: 1 1 1 2
21: 1 1 2 2
22: 1 2
23: 1 2 2 2
24: 2

Compute the number of iterations.

Combine the Lyndon words to form the de Bruijn sequence.

seqseqpk&comma;k=1..lengthP&comma;p=P

0&comma;0&comma;0&comma;0&comma;1&comma;0&comma;0&comma;0&comma;2&comma;0&comma;0&comma;1&comma;1&comma;0&comma;0&comma;1&comma;2&comma;0&comma;0&comma;2&comma;1&comma;0&comma;0&comma;2&comma;2&comma;0&comma;1&comma;0&comma;1&comma;0&comma;2&comma;0&comma;1&comma;1&comma;1&comma;0&comma;1&comma;1&comma;2&comma;0&comma;1&comma;2&comma;1&comma;0&comma;1&comma;2&comma;2&comma;0&comma;2&comma;0&comma;2&comma;1&comma;1&comma;0&comma;2&comma;1&comma;2&comma;0&comma;2&comma;2&comma;1&comma;0&comma;2&comma;2&comma;2&comma;1&comma;1&comma;1&comma;1&comma;2&comma;1&comma;1&comma;2&comma;2&comma;1&comma;2&comma;1&comma;2&comma;2&comma;2&comma;2

(1)

References

  

Knuth, Donald Ervin. The Art of Computer Programming, volume 4, fascicle 2; generating all tuples and permutations, sec. 7.2.1.1, generating all n-tuples, pp. 26-27.

  

ibid, Algorithm F, prime and preprime string generation, p. 27.

Compatibility

• 

The Iterator[DeBruijn] command was introduced in Maple 2020.

• 

For more information on Maple 2020 changes, see Updates in Maple 2020.

• 

The Iterator[DeBruijn] command was updated in Maple 2022.

• 

The n and m parameters were updated in Maple 2022.

See Also

Iterator

LyndonWord

Necklace

Prenecklace