GATE | GATE CS 2018 | Question 46
Consider the following languages:
I. {ambncpdq ∣ m + p = n + q, where m, n, p, q ≥ 0}
II. {ambncpdq ∣ m = n and p = q, where m, n, p, q ≥ 0}
III. {ambncpdq ∣ m = n = p and p ≠ q, where m, n, p, q ≥ 0}
IV. {ambncpdq ∣ mn = p + q, where m, n, p, q ≥ 0}
Which of the above languages are context-free?
(A) I and IV only
(B) I and II only
(C) II and III only
(D) II and IV only
Answer: (B)
Explanation: I. {ambncpdq ∣ m + p = n + q, where m, n, p, q ≥ 0}
m + p = n + q can also be written as m-n = q-p.
See the strings in given language : {ε ab, ad, bc, cd, abcd, abbc, aabb, aadd, acdd, bbcc, ccdd, aaabdd, aaabbd, bcccdd, aabcdd, ………….}
Given language is Context free, so Push Down Automata can be designed for this.
II. {ambncpdq ∣ m = n and p = q, where m, n, p, q ≥ 0}
m = n and p = q
See the strings in given language : { ε, ab, cd, abcd, aabbcd, abccdd, aaabbbccdd, …………}
Definitely Context Free, hence PDA can be designed for this.
III. m=n=p and p ≠ q. Not Context free.
IV. mn = p+q, Not Context free.
Option (B) is Correct.
Please Login to comment...