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.
Past exam of the mathematics course of the University of Cambridge 2021 ii Paper 3 12F i Solution Created 2026-09-24 Updated 2026-09-25
A parse tree has the start variable at its root; the ordered children of a variable spell the right side of the production used at that occurrence, and its leaves, read left to right, spell the derived word.
For a grammar in Chomsky normal form with variables, take pumping length . A parse tree for a word of length at least has a root-to-leaf path containing one variable twice. The yield can therefore be writtenwhere , , and replacing the subtree between the repeated variables zero, one, or several times provesThis is the pumping lemma for context-free languages. Without Chomsky normal form but with no epsilon or unit productions, use the maximum production length to choose a larger exponential ; bounded branching and the same repeated-variable argument apply.
Past exam of the mathematics course of the University of Cambridge 2023 ii Paper 1 4I b Solution Created 2026-09-24 Updated 2026-09-25
The length isIndeed, the parse tree has terminal-production nodes and, as a full binary tree with leaves, binary-production nodes. This is the Chomsky-normal-form derivation length.
Past exam of the mathematics course of the University of Cambridge 2023 ii Paper 1 4I c Solution Created 2026-09-24 Updated 2026-10-03
One parse tree can be recorded unambiguously by the nested expressionEvery internal node uses one of the given productions, and the leaves read from left to right areEquivalently, the corresponding leftmost grammar derivation isHence the required word is generated by the grammar.