GATE Computer ScienceHardGATE CS (PYQ pattern)
Grammar G: S → AB | ASB | ε; A → a | aA | aAS; B → A | Sb | SbS | b | bS | bb. After eliminating the unit production(s) B → A (copy A's productions to B and drop the unit production), how many productions does the grammar have in total?
- A. 12
- B. 14
- C. 15
- D. 13
Correct answer: B. 14
Remove the unit production and add all non-unit productions of A to B: S → ε | AB | ASB; A → a | aA | aAS; B → Sb | SbS | a | aA | aAS | b | bS | bb; total 14.
More Theory of Computation questions
- In the grammar S → AB | aC | b; A → a | aE; B → bB | bD; C → c | cC; D → dD; E → e (start S), how many variables are useless (not…
- In the grammar S → AB | CD; A → aA | BC; B → b | CC; C → AC | c | ε; D → d | DA; E → eE | ε (start S), how many variables are nullable…
- 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…
- For the CNF grammar S → AB | BC; A → BA | a; B → CC | b; C → AB | a, the CYK table for the string aabab has a top cell (the whole string)…
- A TM (blank B, start q0 on the leftmost cell, halting state qa) has rules: δ(q0,1) = (q0,1,R); δ(q0,0) = (q1,1,R); δ(q1,1) = (q1,1,R)…
- For the TM with rules δ(q0,1) = (q0,1,R); δ(q0,0) = (q1,1,R); δ(q1,1) = (q1,1,R); δ(q1,B) = (q2,B,L); δ(q2,1) = (qa,B,R) (start q0 on the…