IAE Academy

GATE 2022 CS Q.48: solution and answer

GATE 2022 · CSQ.48 · 2 marks · MSQ

Consider the following languages:



Which of the following statements is/are FALSE?

  1. (A)

    is not context-free but and are deterministic context-free.

  2. (B)

    Neither nor is context-free.

  3. (C)

    , and all are context-free.

  4. (D)

    Neither nor its complement is context-free.

See the question in the paper

Answer and solution

ANSWER

The false statements are (B), (C) and (D).

Official answer: B, C, DSource: Official answer key, GATE 2022 CS (IIT Kharagpur)

  1. is the copy language. It is not context-free (pumping lemma for CFLs, or the standard result). So the first half of (A) is correct.

  2. is accepted by a DPDA that pushes a symbol for each , pops one for each , then reads any number of 's and accepts on empty stack. So is a deterministic context-free language. A grammar is , , .

  3. is accepted by a DPDA that skips the 's, pushes for each and pops for each . So is a DCFL. Hence statement (A) is TRUE.

  4. Statement (B) says is not context-free. But is context-free by step 2, so (B) is FALSE.

  5. , which is not context-free (pumping lemma for CFLs). Statement (C) claims it is context-free, so (C) is FALSE.

  6. The complement of is context-free. A string over is outside if its length is odd, or if its length is and some position and position hold different symbols. A PDA can guess the position, push a count while reading, and match it against the second half. This gives a CFL. Statement (D) says neither nor its complement is context-free, so (D) is FALSE.

  7. The FALSE statements are B, C and D.

KEY IDEA

is not context-free but its complement is. and are DCFLs, and their intersection is not context-free, so CFLs are not closed under intersection.

WATCH OUT FOR

Assuming that because is not context-free, its complement cannot be either. The complement is context-free because a PDA can guess one mismatching position. Another slip is treating as context-free just because and are.

From the GATE 2022 CS paper. Every question of this paper · Download the full paper · All 8 Context-free languages questions, with notes

More Context-free languages questions