Past exam of the mathematics course of the University of Cambridge 2019 ii Paper 3 4H b Solution Created 2026-09-24 Updated 2026-10-03
Use the CYK algorithm. For a nonempty input word , let be the set of nonterminals that derive the substring . InitializeFor increasing substring lengths, computeAccept exactly when the start symbol belongs to . The proof is a mathematical induction on substring length: a one-letter derivation uses a terminal production, while every longer parse tree has a root production whose two subtrees yield two adjacent nonempty substrings. The recurrence considers every possible split point and therefore finds exactly all possible roots. For a fixed grammar the algorithm uses time. Under the strict form in part (a), it rejects immediately.