de bruijn sequences for fun and profit
TRANSCRIPT
![Page 1: De Bruijn Sequences for Fun and Profit](https://reader031.vdocuments.mx/reader031/viewer/2022020411/587122a61a28abe4448b5649/html5/thumbnails/1.jpg)
De Bruijn Sequences for Fun and Profit
Aleksandar Bradic
CTO, Supplyframe
December 13 2016
![Page 2: De Bruijn Sequences for Fun and Profit](https://reader031.vdocuments.mx/reader031/viewer/2022020411/587122a61a28abe4448b5649/html5/thumbnails/2.jpg)
(motivation)
![Page 3: De Bruijn Sequences for Fun and Profit](https://reader031.vdocuments.mx/reader031/viewer/2022020411/587122a61a28abe4448b5649/html5/thumbnails/3.jpg)
(4-decimal digit combination lock)
k = 10(base); n = 4(length)Number of combinations: 104 = 10, 000 (kn)Total sequence length: 4 ∗ 104 = 40, 000 (nkn)
![Page 4: De Bruijn Sequences for Fun and Profit](https://reader031.vdocuments.mx/reader031/viewer/2022020411/587122a61a28abe4448b5649/html5/thumbnails/4.jpg)
De Bruijn sequence
A cyclic sequence in which every possible length-n string occursexactly once as a substring.
B(k , n) - De Bruijn sequence of order n on a size-k alphabet.
![Page 5: De Bruijn Sequences for Fun and Profit](https://reader031.vdocuments.mx/reader031/viewer/2022020411/587122a61a28abe4448b5649/html5/thumbnails/5.jpg)
B(2,12)
![Page 6: De Bruijn Sequences for Fun and Profit](https://reader031.vdocuments.mx/reader031/viewer/2022020411/587122a61a28abe4448b5649/html5/thumbnails/6.jpg)
![Page 7: De Bruijn Sequences for Fun and Profit](https://reader031.vdocuments.mx/reader031/viewer/2022020411/587122a61a28abe4448b5649/html5/thumbnails/7.jpg)
De Bruijn sequence
I B(k , n) has length kn - the number of distinct substrings oflength n on given alphabet A ⇒ is optimally short.
I B(k , n) is not unique. There are (k!)kn−1
kn distinct B(k , n)sequences.
I ⇒ linear speedup! (O(kn) vs O(nkn))
![Page 8: De Bruijn Sequences for Fun and Profit](https://reader031.vdocuments.mx/reader031/viewer/2022020411/587122a61a28abe4448b5649/html5/thumbnails/8.jpg)
Generation
I Hamiltonian Path on De Bruijn graph
I Using Shift Registers
![Page 9: De Bruijn Sequences for Fun and Profit](https://reader031.vdocuments.mx/reader031/viewer/2022020411/587122a61a28abe4448b5649/html5/thumbnails/9.jpg)
Hamiltonian Path on De Bruijn graph
De Bruijn graph on a set of m symbols S := S1, ....Sm, is adirected graph with mn vertices representing all possible length-nsequences of given symbols:
V = Sn = (s1, ..., s1, s1), (s1, ...., s1, s2), ....., (sm, ...., sm, sm)
and edges representing set of all possible expressions of vertices asanother vertex by shifting all its symbols by one place to the leftand adding a new symbol at the end of this vertex:
E = ((v1, v2, ...., vn), (v2, ...., vn, si )) : i = 1, ...,m
![Page 10: De Bruijn Sequences for Fun and Profit](https://reader031.vdocuments.mx/reader031/viewer/2022020411/587122a61a28abe4448b5649/html5/thumbnails/10.jpg)
Hamiltonian Path on De Bruijn graph
I Each vertex in De Bruijn graph has exactly m incoming and moutgoing edges.
I Each n-dimensional De Bruijn graph is the line digraph of the(n-1)-dimensional De Bruijn graph with the same set ofsymbols.
I Each De Bruijn graph is Eulerian and Hamiltonian.
![Page 11: De Bruijn Sequences for Fun and Profit](https://reader031.vdocuments.mx/reader031/viewer/2022020411/587122a61a28abe4448b5649/html5/thumbnails/11.jpg)
Hamiltonian Path on De Bruijn graphDe Bruijn sequences can be constructed by taking a Hamiltonianpath of an n-dimensional De Bruijn graph over k symbols (or aEulerian cycle of a (n − 1)-dimensional De Bruijn graph).
![Page 12: De Bruijn Sequences for Fun and Profit](https://reader031.vdocuments.mx/reader031/viewer/2022020411/587122a61a28abe4448b5649/html5/thumbnails/12.jpg)
Generation using shift registers
I Generate one digit at the time, and repeatedly work with then most recently generated digits, passing from one tuple(x0, ..., xn−1) to another one (x1, ..., xn−1, xn) by shifting anappropriate new digit in at the right.
![Page 13: De Bruijn Sequences for Fun and Profit](https://reader031.vdocuments.mx/reader031/viewer/2022020411/587122a61a28abe4448b5649/html5/thumbnails/13.jpg)
Generation using shift registers
![Page 14: De Bruijn Sequences for Fun and Profit](https://reader031.vdocuments.mx/reader031/viewer/2022020411/587122a61a28abe4448b5649/html5/thumbnails/14.jpg)
Generation using shift registers
If we want to generate a single order n sequence on the letters(0, 1, . . . k − 1), where k is prime, we can pick an irreduciblepolynomial
xn − bnxn−1 − · · · − b2x − b1 ∈ Zk [x ]
and an initial string of n numbers s1 . . . sn which isn’t 00 . . . 0.The next term in the sequence is defined by:
sn+1 = b1s1 + b2s2 + · · ·+ bnsn ∈ Zk [x ]
![Page 15: De Bruijn Sequences for Fun and Profit](https://reader031.vdocuments.mx/reader031/viewer/2022020411/587122a61a28abe4448b5649/html5/thumbnails/15.jpg)
Applications
I Magic!
I Indexing 1s in a Computer Word
I Fault Tolerant Systems
I Writing detection
![Page 16: De Bruijn Sequences for Fun and Profit](https://reader031.vdocuments.mx/reader031/viewer/2022020411/587122a61a28abe4448b5649/html5/thumbnails/16.jpg)
![Page 17: De Bruijn Sequences for Fun and Profit](https://reader031.vdocuments.mx/reader031/viewer/2022020411/587122a61a28abe4448b5649/html5/thumbnails/17.jpg)
Indexing 1s in a Computer Word
h(x) = (x ∗ deBruijn) >> (n − lgn)
I We assume that n is an exact power of 2. Multiplication isperformed modulo 2n
I deBruijn is a computer word whose bit pattern contains alength-n de Bruijn sequence beginning with lgn zeros.
![Page 18: De Bruijn Sequences for Fun and Profit](https://reader031.vdocuments.mx/reader031/viewer/2022020411/587122a61a28abe4448b5649/html5/thumbnails/18.jpg)
Indexing 1s in a Computer Word
![Page 19: De Bruijn Sequences for Fun and Profit](https://reader031.vdocuments.mx/reader031/viewer/2022020411/587122a61a28abe4448b5649/html5/thumbnails/19.jpg)
Fault Tolerant Systems
I In the binary De Bruijn graphthere will exist 22
n−1−n different Hamiltonian cycles
I De Bruijn graph B(2, n) with a single node failure has a cyclewith at least 2n − n − 1 nodes
![Page 20: De Bruijn Sequences for Fun and Profit](https://reader031.vdocuments.mx/reader031/viewer/2022020411/587122a61a28abe4448b5649/html5/thumbnails/20.jpg)
Writing detection
![Page 21: De Bruijn Sequences for Fun and Profit](https://reader031.vdocuments.mx/reader031/viewer/2022020411/587122a61a28abe4448b5649/html5/thumbnails/21.jpg)
Thanks!