Past exam of the mathematics course of the University of Cambridge 2006 ii Paper 1 4G Solution Created 2026-09-24 Updated 2026-10-14
A binary linear-feedback shift register of length keeps bits and produces a sequence satisfying a recurrenceAfter each output it shifts its stored bits and inserts the feedback bit. Its connection polynomial is . This convention reverses the usual characteristic polynomial .
The Berlekamp-Massey algorithm recovers the shortest recurrence compatible with observed bits. Maintain the current , length , an earlier polynomial that last caused a length increase, and the offset since that increase. Initially . At position calculate the discrepancy . If , advance . If , save and replace by . If also , replace by , by and by one; otherwise increase . Over a general field the correction is , where is the saved nonzero discrepancy. The correction cancels the failed equation while retaining the previous successful ones; when it forces a length increase the smallest possible new length is .
Here, indexing the first bit by zero, the nonzero discrepancies occur at positions . The corresponding updates areEvery subsequent supplied discrepancy is zero. ThusEquivalently the characteristic feedback polynomial is . No length-three recurrence works: positions force , but position six then has nonzero discrepancy. The recovered length is therefore minimal. Observing at least twice the true linear complexity ordinarily identifies the recurrence, after which a known consecutive block determines all future key bits. This is why a bare register is unsuitable as a cryptographic keystream generator; a finite prefix alone does not exclude a longer generator that later diverges.
Past exam of the mathematics course of the University of Cambridge 2007 ii Paper 4 4G Solution Created 2026-09-24 Updated 2026-10-14
A binary linear-feedback shift register stores bits, shifts them at each clock step, and inserts a fixed linear combination over of the stored bits. Its output obeys a recurrence . Write its connection polynomial as ; the corresponding monic feedback polynomial is .
The Berlekamp-Massey algorithm maintains the shortest recurrence fitting the observed prefix. Initialize , length , displacement , and previous nonzero discrepancy . At symbol , calculate . If , increase . If , save and replace by . If , replace by , by , by , and by ; otherwise only increase . In the binary field subtraction equals addition. The shifted previous discrepancy polynomial cancels the current discrepancy while preserving earlier equations. A failed recurrence of length at position requires a corrected length at least when this exceeds , explaining the length update. Thus the algorithm recovers the shortest compatible register; a known bound and at least output symbols suffice to identify its minimal recurrence.
For the printed twelve-bit prefix, the nonzero discrepancies occur at positions (indexing from zero). The successive updated pairs areAll remaining discrepancies vanish. ThereforeThe first four observed bits are the fill. Length four is necessary: a length-three recurrence would need to hold already at and no such recurrence fits the prefix. Indeed the equations at force , , , a contradiction. Finite observations cannot rule out longer nonminimal registers.
Past exam of the mathematics course of the University of Cambridge 2018 ii Paper 4 3H Solution Created 2026-09-24 Updated 2026-10-03
A binary linear-feedback shift register of length stores bits. At each clock it outputs one bit, shifts the state, and inserts a fixed linear combination over of the stored bits. Equivalently, its output obeys a recurrence
The Berlekamp-Massey algorithm processes the observed symbols from left to right. It maintains the shortest current connection polynomial , its degree , and a saved polynomial from the most recent degree increase. At step it computes the discrepancyIf , the current recurrence already predicts the new symbol. If , a shifted multiple of the saved polynomial is added to to cancel the discrepancy; when , the algorithm also replaces by and saves the old polynomial.
For the observed binary sequence, the nonzero-discrepancy updates areAll discrepancies through then vanish. Thus the shortest recurrence isor, equivalently, . The connection polynomial is , and with the reciprocal convention the feedback polynomial is