GATE Computer ScienceHardGATE CS (PYQ pattern)
Grammar G: S → ASB | ε; A → aAS | a; B → SbS | A | bb. After eliminating all ε-productions in the standard way (every way of deleting nullable variables from each production is added, A → ε is removed, but S → ε is kept because ε ∈ L(G)), how many productions does the new grammar have in total?
- A. 7
- B. 10
- C. 15
- D. 12
Correct answer: D. 12
Only S is nullable. Each production containing S spawns variants with S deleted: S → AB | ASB | ε; A → a | aA | aAS; B → A | Sb | SbS | b | bS | bb, a total of 12 productions.
More Theory of Computation questions
- 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…
- 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)…