ISRO | ISRO CS 2017 | Question 23
Identify the language generated by the following grammar
S -> AB A -> aAb|ϵ B -> bB| b
(A) {ambn | n>=m, m>0}
(B) {ambn | n>=m, m>=0}
(C) {ambn | n>m, m>0}
(D) {ambn | n>m, m>=0}
Answer: (D)
Explanation:
S -> AB A -> aAb|ϵ B -> bB| b
strings generated by the the language:
b, bb, abb, abbb, aabbb and so on.
Alternative way –
The production rule B -> bB| b will generate bp, p ≥ 1
The production rule A -> aAb|ϵ will generate ambm, n ≥ 0
The production rule S -> AB will generate amb(m+p), i.e.,
{ambn | n>m, m>=0}
So option (D) is correct.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.