Open In App

GATE | GATE-CS-2006 | Question 84

Like Article
Like
Save
Share
Report

Which one of the following grammars generates the language L = {ai bj | i ≠ j}

 


(A)

A

(B)

B

(C)

C

(D)

D



Answer: (D)

Explanation:

Language L contains the strings: (abb, aab, abbb, aabbb, aaabb, aa, bb, …….), i.e.  all a’s appear before b’s in a string, and “number of a’s” is not equal to “number of b’s”, So i ≠ j.

Here Grammar A, B & C also generate the string “ab”, where i = j, and many more strings with i = j, hence these grammars do not generate the language L, because for a string that belongs to language L, exponent i should not be equal to exponent j.

Grammar D: This Grammar never generates a string with equal no of a’s and b’s, i.e. ij. 
Hence this grammar generates the language L. 

Hence Option D is the correct answer


Quiz of this Question
Please comment below if you find anything wrong in the above post


Last Updated : 28 Jun, 2021
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads