GATE Computer ScienceVery hardGATE CS (PYQ pattern)

A CNF grammar has productions S → AB | BC; A → BA | a; B → CC | b; C → AB | a. The CYK algorithm is run on the string baaba, filling a triangular table with the set of variables deriving each substring. What is the total number of variables (counted over all 15 cells) that appear in the table?

  1. A. 25
  2. B. 23
  3. C. 21
  4. D. 15

Correct answer: B. 23

Filling cell by cell (substrings of length 1, then 2, …, 5) gives 23 variable entries in total; S appears in the top cell: True.

More Theory of Computation questions

Exams that ask this topic