Gate2018 cs Q50

0. 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 language above are context-free?

  • Option : B
  • Explanation :
    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, and pop and check if stack is empty at end.
    II {ambncpdq | m = n and p = q} is clearly CFL since, one comparison at a time can be done by pda
    III {ambncpdq | m = n = p and p ≠ q} is not CFL since m = n = p is a double comparison 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.
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *