Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

GATE | GATE CS 2018 | Question 46

  • Last Updated : 01 Oct, 2021

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}

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.

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.


Quiz of this Question

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!