Greedy Construction  Output  

Perhaps the most surprising DB sequence constructions are the greedy constructions. A greedy construction starts with a seed string, then repeatedly applies some greedy rule to determine the next symbol of a sequence. The algorithm stops when it is impossible to add another symbol without creating a duplicate substring of length $n$, or some termination condition is reached. Such constructions, however, have a major drawback: they require exponential space.
The Preferlargest [Mar34] (smallest) greedy approach does not use any information about the string currently generated to prioritize the next symbol. There are two approaches whose greedy decision is based on the last symbol generated: the Preferopposite [Alh10] and the Prefersame [EGGR58,Fre82,ASS21]. These greedy approaches can be extended when the preferences are based more generally on the last $j$ symbols generated [Alh12], and in fact they are all special cases of an Euler cycle construction based on the de Bruijn graph.
The most wellknown greedy construction is the Preferlargest [Mar34], which generates the lexicographically largest DB sequence.
Note the importance of the string $0^{n1}$ to seed the algorithm. Starting with any other seed will not produce a DB sequence using this greedy approach.
The Prefersmallest is equivalent to the Preferlargest construction when the symbol 0 is replaced by $k{}1$, 1 is replaced by $k{}2$ and so on. The Prefersmallest greedy algorithm produces the lexicographically smallest DB sequence, and it can be constructed more efficiently by either a shift rule or by a concatenation approach.
The original presentations of a binary Prefersame construction [EGGR58,Fre82] required an additional counting test for certain substrings. However, when seeded with an appropriate string, as described in the related Euler cycle algorithms, these tests are not required [ASS21].
The resulting sequence is lexicographically largest with respect to a runlength encoding. For example, the runlength encoding of the generated DB sequence for $n=5$ is given by: $$11111000001110110011010001001010 = 5531222113121111.$$ Note that this property holds when the roles of the 0 and 1 are interchanged. The binary Prefersame sequence can also be constructed efficiently in $O(n)$ time per bit via a shift rule. One way to generalize this greedy construction to a larger alphabet of size $k$:
A strict Preferopposite approach does not yield a DB sequence. However, as described in the section on de Bruijn graphs, by modifying the preference for the special vertex $1^{n1}$ in the underlying Euler cycle algorithm, we indeed obtain a DB sequence. The algorithm presented below produces a shifted instance of the originally presented sequence in [Alh10]. Here, the initial seed of $0^{n1}$ is rotated to the end so the resulting sequence is lexicographically smallest with respect to a runlength encoding [ASS21].
The binary Preferopposite sequence can also be constructed efficiently in $O(n)$ time per bit via a shift rule. One way to generalize this construction to a larger alphabet size $k$:
These special case strings all occur in the final $kn$ symbols of the resulting sequence. Try it out above!