IAE Academy

GATE 2022 CS Q.23: solution and answer

GATE 2022 · CSQ.23 · 1 mark · MSQ

Which of the following statements is/are TRUE?

  1. (A)

    Every subset of a recursively enumerable language is recursive.

  2. (B)

    If a language and its complement are both recursively enumerable, then must be recursive.

  3. (C)

    Complement of a context-free language must be recursive.

  4. (D)

    If and are regular, then must be deterministic context-free.

See the question in the paper

Answer and solution

ANSWER

Statements (B), (C) and (D) are true; (A) is false.

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

  1. (A) Take , which is recursive and hence recursively enumerable. Every language over is a subset of . There are uncountably many languages over but only countably many Turing machines, so some subset of is not even recursively enumerable, let alone recursive. (A) is false.

  2. (B) Let accept and accept . On input , run and alternately, one step at a time. Every string lies in exactly one of and , so exactly one of the two machines eventually accepts. If accepts, accept . If accepts, reject . This machine halts on every input and decides , so is recursive. (B) is true.

  3. (C) Every context-free language is decidable, for example by the CYK algorithm on a grammar in Chomsky normal form, which always halts. Swapping the accept and reject outcomes of this decider gives a decider for the complement. So the complement of a context-free language is recursive, even though it need not be context-free. (C) is true.

  4. (D) Regular languages are closed under intersection, so is regular. A DFA is a deterministic pushdown automaton that never uses its stack, so every regular language is deterministic context-free. (D) is true.

  5. Correct options: B, C and D.

KEY IDEA

A language is recursive exactly when both it and its complement are recursively enumerable. Every context-free language is decidable, so its complement is recursive even when it is not context-free. Regular languages sit inside the deterministic context-free languages.

WATCH OUT FOR

Concluding that (C) is false because context-free languages are not closed under complement. They are not closed, but the complement is still decidable, and the option only asks for recursive, not context-free.

From the GATE 2022 CS paper. Every question of this paper · Download the full paper · All 8 Turing machines questions, with notes

More Turing machines questions