Related Articles

# GATE | Gate IT 2008 | Question 32

• Last Updated : 28 Jun, 2021

Consider a CFG with the following productions.

S → AA | B
A → 0A | A0 | 1
B → 0B00 | 1

S is the start symbol, A and B are non-terminals and 0 and 1 are the terminals. The language generated by this grammar is
(A) {0n 102n | n ≥ 1}
(B) {0i 10j 10k | i, j, k ≥ 0} ∪ {0n 102n | n ≥ l}
(C) {0i 10j | i, j ≥ 0} ∪ {0n 102n | n ≥ l}
(D) The set of all strings over {0, 1} containing at least two 0’s
(E) None of the above

Explanation:

A− > 0A|A0|1 This production rule individually produces a CFL of the form {0i 10j |i, j ≥ 0}
B− > 0B00|1 This production rule individually produces a CFL of the form {0n102n |n ≥ 0}
S− > AA|B This production rule concatenates A’s CFL with itself and unions it with B’s CFL.
Hence, CFL accepted by the given CFG will be {0n102n|n ≥ 0} ∪ {0i 10j 10k |i, j, k ≥ 0}
According to our derivation, as none of the given CFL matches to our derived CFL, correct option

should be (E) None of the above.

This solution is contributed by vineet purswani.

Quiz of this Question

Attention reader! Don’t stop learning now.  Practice GATE exam well before the actual exam with the subject-wise and overall quizzes available in GATE Test Series Course.

Learn all GATE CS concepts with Free Live Classes on our youtube channel.

My Personal Notes arrow_drop_up