wiz-icon
MyQuestionIcon
MyQuestionIcon
1
You visited us 1 times! Enjoying our articles? Unlock Full Access!
Question

Consider the following languages:
I. {ambncpdq | m+p=n+q, where m,n,p,q0}
II. {ambncpdq | m=n and p=q, where m,n,p,q0}
III. {ambncpdq | m=n=p and pq, where m,n,p,q0}
IV. {ambncpdq | mn=p+q, where m,n,p,q0}
Which of the language above are context-free?

A
II and IV only
No worries! We‘ve got your back. Try BYJU‘S free classes today!
B
I and IV only
No worries! We‘ve got your back. Try BYJU‘S free classes today!
C
II and III only
No worries! We‘ve got your back. Try BYJU‘S free classes today!
D
I and II only
Right on! Give the BNAT exam to get a 100% scholarship for BYJUS courses
Open in App
Solution

The correct option is D I and II only
I. {ambncpdq | m+p=n+q} is clearly CFL since, we can rearrange the equation as m - n + p - q = 0 which can be done by push, pop, push and pop and check if stack is empty at end.
II. {ambncpdq | m=n and p=q} is clearly CFL since, one comparision at a time can be done by pda.
III. {ambncpdq | m=n=p and pq} is not CFL since m = n = p is a double comparision which cannot be done by PDA.
IV. {ambncpdq | mn=p+q} is not a CFL, since mn involves multiplying number of a's and number b's which cannot be done by a PDA.
So,only I and II are CFL's.

flag
Suggest Corrections
thumbs-up
0
Join BYJU'S Learning Program
similar_icon
Related Videos
thumbnail
lock
Context-Free Grammars
OTHER
Watch in App
Join BYJU'S Learning Program
CrossIcon