Cheat sheets

TOC-10Cheat sheet1 pageIn a paid pack

CFGs: Derivations and Ambiguity

Context-free grammars as 4-tuples, derivations, sentential forms and yields, the one-to-one link between parse trees and leftmost derivations, ambiguous grammars and how to show ambiguity, standard ambiguous grammars and their unambiguous rewrites (precedence, associativity, dangling else), inherent ambiguity, the grammar-to-language table for standard grammars, and the solved 2026 question on counting derivations. Every language and parse-tree count was computed by script.

Diagrams from TOC-10

TOC-11Cheat sheet1 pageIn a paid pack

Simplifying Grammars, CNF, GNF and CYK

Grammar simplification for GATE CS: removing useless symbols (non-generating first, then unreachable, with the counterexample for the wrong order), epsilon-productions via nullable variables, and unit productions via unit pairs; Chomsky normal form and its conversion steps, Greibach normal form, exact derivation lengths (2n - 1 in CNF, n in GNF) and parse-tree shape; and the CYK membership algorithm with a full table for a small CNF grammar. Every transformed grammar was compared with the original on all strings up to length 9 or 10.