GATE Computer ScienceModerateGATE CS (PYQ pattern)
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 (derive ε)?
- A. 5
- B. 3
- C. 4
- D. 2
Correct answer: A. 5
C is nullable directly; B → CC so B is; A → BC so A is; S → AB so S is. E → ε makes E nullable even though it is unreachable (usefulness is a separate question). D is not nullable: both its rules contain d or D itself. Hence S, A, B, C, E: 5.
More Theory of Computation questions
- 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…
- A TM with rules δ(q0,a) = (q1,X,R); δ(q0,Y) = (q3,Y,R); δ(q1,a) = (q1,a,R); δ(q1,Y) = (q1,Y,R); δ(q1,b) = (q2,Y,L); δ(q2,a) = (q2,a,L)…
- A single-tape TM (blank B, start q0 on the leftmost cell, accepting state qa) has rules: δ(q0,0) = (q1,B,R); δ(q0,1) = (q4,B,R); δ(q0,B) =…