Skip to main content

GATE CSE 2020Theory of Computation › Language Classification, Closure Properties & ProofsVerified

GATE CSE 2020 PYQ: Consider the language L = { a n ∣ n ≥ 0 } ∪ { a n b n ∣ n ≥ 0 } L = \{a^{n}\mid n \geq 0\} \cup…

Consider the language L={an∣n≥0}∪{anbn∣n≥0}L = \{a^{n}\mid n \geq 0\} \cup \{a^{n}b^{n}\mid n \geq 0\} and the following statements.

  1. LL is deterministic context-free.
  2. LL is context-free but not deterministic context-free.
  3. LL is not LL(k)LL(k) for any kk.

 Which of the above statements is/are TRUE?

  1. A
    Ⅰ only
  2. B
    Ⅱ only
  3. C
    Ⅰ and Ⅲ only
    Correct answer
  4. D
    Ⅲ only

Answer

(C) Ⅰ and Ⅲ only

Approach

Split L into a regular part a* and a DCFL part ${a^n b^n}$, use the closure of DCFL under union with a regular language to settle statements Ⅰ and Ⅱ, then argue about LL(k) lookahead limitations for statement Ⅲ.

L is the union of the regular language a* with the DCFL {aⁿbⁿ}. DCFLs are closed under union with regular languages, so L is deterministic context-free (Ⅰ true, Ⅱ false). No LL(k) parser can distinguish $a^(k+1)$ from $a^(k+1)b^(k+1)$ when n is unbounded, so L is not LL(k) for any k (Ⅲ true). Hence option C.

Reviewed by GateIQ Editorial Team: IIT & IISc Alumni.