In combinatorialmathematics, a de Bruijn sequence of order n on a size-kalphabetA is a cyclic sequence in which every possible length-nstring on A occurs exactly once as a substring (i.e., as a contiguoussubsequence). Such a sequence is denoted by B(k, n) and has length kn, which is also the number of distinct strings of length n on A. Each of these distinct strings, when taken as a substring of B(k, n), must start at a different position, because substrings starting at the same position are not distinct. Therefore, B(k, n) must have at leastkn symbols. And since B(k, n) has exactlykn symbols, de Bruijn sequences are optimally short with respect to the property of containing every string of length n at least once.
The number of distinct de Bruijn sequences B(k, n) is
The sequences are named after the Dutch mathematician Nicolaas Govert de Bruijn, who wrote about them in 1946.[1] As he later wrote,[2] the existence of de Bruijn sequences for each order together with the above properties were first proved, for the case of alphabets with two elements, by Camille Flye Sainte-Marie (1894). The generalization to larger alphabets is due to Tatyana van Aardenne-Ehrenfest and de Bruijn (1951). Automata for recognizing these sequences are denoted as de Bruijn automata.
In most applications, A = {0,1}.
History
The earliest known example of a de Bruijn sequence comes from Sanskrit prosody where, since the work of Pingala, each possible three-syllable pattern of long and short syllables is given a name, such as 'y' for short–long–long and 'm' for long–long–long. To remember these names, the mnemonic yamātārājabhānasalagām is used, in which each three-syllable pattern occurs starting at its name: 'yamātā' has a short–long–long pattern, 'mātārā' has a long–long–long pattern, and so on, until 'salagām' which has a short–short–long pattern. This mnemonic, equivalent to a de Bruijn sequence on binary 3-tuples, is of unknown antiquity, but is at least as old as Charles Philip Brown's 1869 book on Sanskrit prosody that mentions it and considers it "an ancient line, written by Pāṇini".[3]
In 1894, A. de Rivière raised the question in an issue of the French problem journal L'Intermédiaire des Mathématiciens, of the existence of a circular arrangement of zeroes and ones of size that contains all binary sequences of length . The problem was solved (in the affirmative), along with the count of distinct solutions, by Camille Flye Sainte-Marie in the same year.[2] This was largely forgotten, and Martin (1934) proved the existence of such cycles for general alphabet size in place of 2, with an algorithm for constructing them. Finally, when in 1944 Kees Posthumusconjectured the count for binary sequences, de Bruijn proved the conjecture in 1946, through which the problem became well-known.[2]
Taking A = {0, 1}, there are two distinct B(2, 3): 00010111 and 11101000, one being the reverse or negation of the other.
Two of the 16 possible B(2, 4) in the same alphabet are 0000100110101111 and 0000111101100101.
Two of the 2048 possible B(2, 5) in the same alphabet are 00000100011001010011101011011111 and 00000101001000111110111001101011.
Construction
The de Bruijn sequences can be constructed by taking a Hamiltonian path of an n-dimensional de Bruijn graph over k symbols (or equivalently, an Eulerian cycle of an (n − 1)-dimensional de Bruijn graph).[5]
An alternative construction involves concatenating together, in lexicographic order, all the Lyndon words whose length divides n.[6]
An inverse Burrows–Wheeler transform can be used to generate the required Lyndon words in lexicographic order.[7]
Goal: to construct a B(2, 4) de Bruijn sequence of length 24 = 16 using Eulerian (n − 1 = 4 − 1 = 3) 3-D de Bruijn graph cycle.
Each edge in this 3-dimensional de Bruijn graph corresponds to a sequence of four digits: the three digits that label the vertex that the edge is leaving followed by the one that labels the edge. If one traverses the edge labeled 1 from 000, one arrives at 001, thereby indicating the presence of the subsequence 0001 in the de Bruijn sequence. To traverse each edge exactly once is to use each of the 16 four-digit sequences exactly once.
For example, suppose we follow the following Eulerian path through these vertices:
000, 000, 001, 011, 111, 111, 110, 101, 011,
110, 100, 001, 010, 101, 010, 100, 000.
These are the output sequences of length k:
0 0 0 0
_ 0 0 0 1
_ _ 0 0 1 1
This corresponds to the following de Bruijn sequence:
0 0 0 0 1 1 1 1 0 1 1 0 0 1 0 1
The eight vertices appear in the sequence in the following way:
...and then we return to the starting point. Each of the eight 3-digit sequences (corresponding to the eight vertices) appears exactly twice, and each of the sixteen 4-digit sequences (corresponding to the 16 edges) appears exactly once.
Example using inverse Burrows—Wheeler transform
Mathematically, an inverse Burrows—Wheeler transform on a word w generates a multi-set of equivalence classes consisting of strings and their rotations.[7] These equivalence classes of strings each contain a Lyndon word as a unique minimum element, so the inverse Burrows—Wheeler transform can be considered to generate a set of Lyndon words. It can be shown that if we perform the inverse Burrows—Wheeler transform on a word w consisting of the size-k alphabet repeated kn−1 times (so that it will produce a word the same length as the desired de Bruijn sequence), then the result will be the set of all Lyndon words whose length divides n. It follows that arranging these Lyndon words in lexicographic order will yield a de Bruijn sequence B(k,n), and that this will be the first de Bruijn sequence in lexicographic order. The following method can be used to perform the inverse Burrows—Wheeler transform, using its standard permutation:
Sort the characters in the string w, yielding a new string w′
Position the string w′ above the string w, and map each letter's position in w′ to its position in w while preserving order. This process defines the Standard Permutation.
Write this permutation in cycle notation with the smallest position in each cycle first, and the cycles sorted in increasing order.
For each cycle, replace each number with the corresponding letter from string w′ in that position.
Each cycle has now become a Lyndon word, and they are arranged in lexicographic order, so dropping the parentheses yields the first de Bruijn sequence.
For example, to construct the smallest B(2,4) de Bruijn sequence of length 24 = 16, repeat the alphabet (ab) 8 times yielding w=abababababababab. Sort the characters in w, yielding w′=aaaaaaaabbbbbbbb. Position w′ above w as shown, and map each element in w′ to the corresponding element in w by drawing a line. Number the columns as shown so we can read the cycles of the permutation:
Starting from the left, the Standard Permutation notation cycles are: (1) (2 3 5 9) (4 7 13 10) (6 11) (8 15 14 12) (16). (Standard Permutation)
Then, replacing each number by the corresponding letter in w′ from that column yields: (a)(aaab)(aabb)(ab)(abbb)(b).
These are all of the Lyndon words whose length divides 4, in lexicographic order, so dropping the parentheses gives B(2,4) = aaaabaabbababbbb.
Algorithm
The following Python code calculates a de Bruijn sequence, given k and n, based on an algorithm from Frank Ruskey's Combinatorial Generation.[10]
fromtypingimportIterable,Anydefde_bruijn(k:Iterable[str]|int,n:int)->str:"""de Bruijn sequence for alphabet k and subsequences of length n. """# Two kinds of alphabet input: an integer expands# to a list of integers as the alphabet..ifisinstance(k,int):alphabet=list(map(str,range(k)))else:# While any sort of list becomes used as it isalphabet=kk=len(k)a=[0]*k*nsequence=[]defdb(t,p):ift>n:ifn%p==0:sequence.extend(a[1:p+1])else:a[t]=a[t-p]db(t+1,p)forjinrange(a[t-p]+1,k):a[t]=jdb(t+1,t)db(1,1)return"".join(alphabet[i]foriinsequence)print(de_bruijn(2,3))print(de_bruijn("abcd",2))
which prints
00010111
aabacadbbcbdccdd
Note that these sequences are understood to "wrap around" in a cycle. For example, the first sequence contains 110 and 100 in this fashion.
Uses
de Bruijn cycles are of general use in neuroscience and psychology experiments that examine the effect of stimulus order upon neural systems,[11] and can be specially crafted for use with functional magnetic resonance imaging.[12]
Angle detection
The symbols of a de Bruijn sequence written around a circular object (such as a wheel of a robot) can be used to identify its angle by examining the n consecutive symbols facing a fixed point. This angle-encoding problem is known as the "rotating drum problem".[13]Gray codes can be used as similar rotary positional encoding mechanisms, a method commonly found in rotary encoders.
Finding least- or most-significant set bit in a word
A de Bruijn sequence can be used to quickly find the index of the least significant set bit ("right-most 1") or the most significant set bit ("left-most 1") in a word using bitwise operations and multiplication.[14] The following example uses a de Bruijn sequence to determine the index of the least significant set bit (equivalent to counting the number of trailing '0' bits) in a 32 bit unsigned integer:
The lowestBitIndex() function returns the index of the least-significant set bit in v, or zero if v has no set bits. The constant 0x077CB531U in the expression is the B (2, 5) sequence 0000 0111 0111 1100 1011 0101 0011 0001 (spaces added for clarity). The operation (v & -v) zeros all bits except the least-significant bit set, resulting in a new value which is a power of 2. This power of 2 is multiplied (arithmetic modulo 232) by the de Bruijn sequence, thus producing a 32-bit product in which the bit sequence of the 5 MSBs is unique for each power of 2. The 5 MSBs are shifted into the LSB positions to produce a hash code in the range [0, 31], which is then used as an index into hash table BitPositionLookup. The selected hash table value is the bit index of the least significant set bit in v.
The following example determines the index of the most significant bit set in a 32 bit unsigned integer:
In the above example an alternative de Bruijn sequence (0x06EB14F9U) is used, with corresponding reordering of array values. The choice of this particular de Bruijn sequence is arbitrary, but the hash table values must be ordered to match the chosen de Bruijn sequence. The keepHighestBit() function zeros all bits except the most-significant set bit, resulting in a value which is a power of 2, which is then processed as in the previous example.
Brute-force attacks on locks
B{10,3} with digits read from top to bottom then left to right;[15] appending "00" yields a string to brute-force a 3-digit combination lock
0
1
2
3
4
5
6
7
8
9
001
002
003
004
005
006
007
008
009
011
012
112
013
113
014
114
015
115
016
116
017
117
018
118
019
119
021
022
122
023
123
223
024
124
224
025
125
225
026
126
226
027
127
227
028
128
228
029
129
229
031
032
132
033
133
233
034
134
234
334
035
135
235
335
036
136
236
336
037
137
237
337
038
138
238
338
039
139
239
339
041
042
142
043
143
243
044
144
244
344
045
145
245
345
445
046
146
246
346
446
047
147
247
347
447
048
148
248
348
448
049
149
249
349
449
051
052
152
053
153
253
054
154
254
354
055
155
255
355
455
056
156
256
356
456
556
057
157
257
357
457
557
058
158
258
358
458
558
059
159
259
359
459
559
061
062
162
063
163
263
064
164
264
364
065
165
265
365
465
066
166
266
366
466
566
067
167
267
367
467
567
667
068
168
268
368
468
568
668
069
169
269
369
469
569
669
071
072
172
073
173
273
074
174
274
374
075
175
275
375
475
076
176
276
376
476
576
077
177
277
377
477
577
677
078
178
278
378
478
578
678
778
079
179
279
379
479
579
679
779
081
082
182
083
183
283
084
184
284
384
085
185
285
385
485
086
186
286
386
486
586
087
187
287
387
487
587
687
088
188
288
388
488
588
688
788
089
189
289
389
489
589
689
789
889
091
092
192
093
193
293
094
194
294
394
095
195
295
395
495
096
196
296
396
496
596
097
197
297
397
497
597
697
098
198
298
398
498
598
698
798
099
199
299
399
499
599
699
799
899
(00)
A de Bruijn sequence can be used to shorten a brute-force attack on a PIN-like code lock that does not have an "enter" key and accepts the last n digits entered. For example, a digital door lock with a 4-digit code (each digit having 10 possibilities, from 0 to 9) would have B (10, 4) solutions, with length 10000. Therefore, only at most 10000 + 3 = 10003 (as the solutions are cyclic) presses are needed to open the lock, whereas trying all codes separately would require 4 × 10000 = 40000 presses.
f-fold de Bruijn sequences
An f-fold n-ary de Bruijn sequence is an extension of the notion n-ary de Bruijn sequence, such that the sequence of the length contains every possible subsequence of the length n exactly f times. For example, for the cyclic sequences 11100010 and 11101000 are two-fold binary de Bruijn sequences. The number of two-fold de Bruijn sequences, for is , the other known numbers[16] are , , and .
A de Bruijn torus is a toroidal array with the property that every k-ary m-by-n matrix occurs exactly once.
Such a pattern can be used for two-dimensional positional encoding in a fashion analogous to that described above for rotary encoding. Position can be determined by examining the m-by-n matrix directly adjacent to the sensor, and calculating its position on the de Bruijn torus.
de Bruijn decoding
Computing the position of a particular unique tuple or matrix in a de Bruijn sequence or torus is known as the de Bruijn decoding problem. Efficient decoding algorithms exist for special, recursively constructed sequences[17] and extend to the two-dimensional case.[18] de Bruijn decoding is of interest, e.g., in cases where large sequences or tori are used for positional encoding.
Stein, Sherman K. (1963). "Yamátárájabhánasalagám". The Man-made Universe: An Introduction to the Spirit of Mathematics. pp. 110–118. Reprinted in Wardhaugh, Benjamin, ed. (2012), A Wealth of Numbers: An Anthology of 500 Years of Popular Mathematics Writing, Princeton University Press, pp. 139–144.
BunderDesaKantor Desa BunderPeta lokasi Desa BunderNegara IndonesiaProvinsiJawa TimurKabupatenBanyuwangiKecamatanKabatKode pos68461Kode Kemendagri35.10.14.2002 Luas... km²Jumlah penduduk... jiwaKepadatan... jiwa/km² Bunder adalah sebuah nama desa di wilayah Kabat, Kabupaten Banyuwangi, Provinsi Jawa Timur, Indonesia. Pembagian Wilayah Desa Bunder terdiri dari 5 dusun Dusun Kelir Dusun Krajan Dusun Mulyosari Dusun Sangkur Dusun Sruni Galeri Gerbang Desa Bunder Pranala luar Situs resmi P...
وستباري الإحداثيات 40°45′32″N 73°35′17″W / 40.7589°N 73.5881°W / 40.7589; -73.5881 [1] تقسيم إداري البلد الولايات المتحدة[2][3] التقسيم الأعلى هيمبستيد خصائص جغرافية المساحة 6.1 كيلومتر مربع6.14843 كيلومتر مربع (1 أبريل 2010) ارتفاع 31 متر عدد السكان ...
Formula One 2002 PublikasiGenreRacingKarakteristik teknisPlatformPlayStation 2 Modepermainan video multipemain FormatDVD Format kode Daftar 30 Informasi pengembangPengembangSony Studio LiverpoolPenyuntingSony Interactive Entertainment PenerbitSCEEInformasi tambahanMobyGamesformula-one-2002 Portal permainan videoSunting di Wikidata • L • B • PWBantuan penggunaan templat ini Formula One 2002 merupakan permainan video yang berbasis dari seri balap mobil Formula Satu yang dik...
This article does not cite any sources. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.Find sources: Acrelândia – news · newspapers · books · scholar · JSTOR (August 2013) (Learn how and when to remove this template message) 09°49′40″S 66°52′58″W / 9.82778°S 66.88278°W / -9.82778; -66.88278 Municipality in Acre, BrazilAcrelândiaMunicipality...
1938 film This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.Find sources: The Citadel 1938 film – news · newspapers · books · scholar · JSTOR (January 2017) (Learn how and when to remove this template message) The CitadelDirected byKing VidorScreenplay byIan DalrympleFrank WeadElizabeth HillBased onThe Citadel1937 nove...
This article is about the municipality in Albania. For the river with the same name, see Fan (river). For other uses, see Fan. Municipal unit in Lezhë, AlbaniaFanMunicipal unitFanCoordinates: 41°56′N 20°9′E / 41.933°N 20.150°E / 41.933; 20.150Country AlbaniaCountyLezhëMunicipalityMirditëPopulation (2011) • Municipal unit2,977Time zoneUTC+1 (CET) • Summer (DST)UTC+2 (CEST) Fan is a village and a former municipality in the Lez...
متوازي مستطيلاتمعلومات عامةالنوع متوازي السطوح — مستطيل فائق — موشور قائمتعديل - تعديل مصدري - تعديل ويكي بيانات متوازي المستطيلات في الهندسة الرياضية، متوازي المستطيلات هو المجسم الذي يحيط به ستة مستطيلات من جميع جهاته.[1][2][3] تكون جميع زواياه قائمة، وتكون ا�...
Austrian composer (1819–1895) Suppé, 1846 Franz von Suppé, born Francesco Ezechiele Ermenegildo de Suppé (18 April 1819 – 21 May 1895) was an Austrian composer of light operas and other theatre music. He came from the Kingdom of Dalmatia, Austro-Hungarian Empire (now part of Croatia). A composer and conductor of the Romantic period, he is notable for his four dozen operettas, including the first operetta to a German libretto. Some of them remain in the repertory, particula...
سان مارينو (بالإيطالية: Repubblica di San Marino) سان مارينوعلم سان مارينو سان مارينوشعار سان مارينو [لغات أخرى] الشعار الوطني(باللاتينية: Libertas) النشيد: نشيد سان مارينو الوطني الأرض والسكان إحداثيات 43°56′00″N 12°28′00″E / 43.933333333333°N 12.4666666666...
Ongoing COVID-19 viral pandemic in Saudi Arabia COVID-19 pandemic in Saudi ArabiaGraph showing COVID-19 cases and deaths in Saudi Arabia from April 2020 to April 2023 DiseaseCOVID-19Virus strainSARS-CoV-2LocationSaudi ArabiaFirst outbreakWuhan, Hubei, ChinaIndex caseQatif, Eastern ProvinceArrival date2 March 2020(4 years, 3 months, 1 week and 5 days)Confirmed cases 547,402Active cases 2,223Critical cases 150Recovered 536,447Deaths 8,922 (official) 14,000–99,000 (The Econ...
Mountain building event caused by the collision of Laurentia, Baltica and Avalonia Caledonian Mountains redirects here. Not to be confused with Caledonia Mountain or Mountains of Scotland. Location of the different branches of the Caledonian/Acadian belts at the end of the Caledonian orogeny (Early Devonian). Present-day coastlines are indicated in gray for reference. Later in geological history, the Atlantic Ocean opened and the different parts of the orogenic belt moved apart.[1] Se...
يفتقر محتوى هذه المقالة إلى الاستشهاد بمصادر. فضلاً، ساهم في تطوير هذه المقالة من خلال إضافة مصادر موثوق بها. أي معلومات غير موثقة يمكن التشكيك بها وإزالتها. (ديسمبر 2018) أنشأت بلغاريا تقاليد في مجموعة كبيرة ومتنوعة من الألعاب الرياضية. بلغاريا في الألعاب الأولمبية المقالة �...
Artikel ini tidak memiliki referensi atau sumber tepercaya sehingga isinya tidak bisa dipastikan. Tolong bantu perbaiki artikel ini dengan menambahkan referensi yang layak. Tulisan tanpa sumber dapat dipertanyakan dan dihapus sewaktu-waktu.Cari sumber: Raqib – berita · surat kabar · buku · cendekiawan · JSTOR Bagian dari seriIslam Rukun Iman Keesaan Allah Malaikat Kitab-kitab Allah Nabi dan Rasul Allah Hari Kiamat Qada dan Qadar Rukun Islam Syahadat Sa...
لمعانٍ أخرى، طالع محمد علي (توضيح). سمو الأمير ولي العهد محمد علي باشا توفيق معلومات شخصية الميلاد 9 نوفمبر 1875(1875-11-09) - الإسكندرية الوفاة 17 مارس 1954 (78 سنة) سويسرا سبب الوفاة تسمم ⚔ مكان الدفن المملكة المصرية - القاهرة الإقامة القاهرة الجنسية الدولة العثماني...
Flowering, deciduous trees, family Ulmaceae For other uses, see Elm (disambiguation). ElmTemporal range: Paleocene–Recent PreꞒ Ꞓ O S D C P T J K Pg N U. minor, East Coker Scientific classification Kingdom: Plantae Clade: Tracheophytes Clade: Angiosperms Clade: Eudicots Clade: Rosids Order: Rosales Family: Ulmaceae Genus: UlmusL. Species See List of elm species List of elm cultivars, hybrids and hybrid cultivars List of elm synonyms and accepted names Elms are deciduous and semi-deciduou...
بلكرام تقسيم إداري البلد الهند (15 أغسطس 1947–) [1] التقسيم الأعلى منطقة هاردوي (1859–) خصائص جغرافية إحداثيات 27°11′N 80°02′E / 27.18°N 80.03°E / 27.18; 80.03 المساحة 5 كيلومتر مربع الارتفاع 136 متر معلومات أخرى التوقيت ت ع م+05:30 الرمز البريدي 241301 الرمز الج�...