GateAI
Context-Free Grammars and PDAs

GATE CSE 2020 · Q10

MCQ1 markMedium

Time

Consider the language L={an∣n≥0}∪{anbn∣n≥0}L = \{a^n \mid n \ge 0\} \cup \{a^n b^n \mid n \ge 0\} and the following statements. I. LL is deterministic context-free. II. LL is context-free but not deterministic context-free. III. LL is not LL(kk) for any kk. Which of the above statements is/are TRUE?

Select one answerSingle correct

Pick an option to check

Solution

Step-by-step verified solution

Official answer: C) I and III only

Context-Free Grammars and PDAs
  1. Deterministic Context-Free Language (DCFL): A DPDA can accept LL. While reading aa's, the DPDA pushes each aa onto the stack and remains in an accepting state (so any prefix ana^n is accepted if the input ends). If a symbol bb is encountered, the automaton moves to a non-accepting state and begins popping aa's for each bb. When the stack becomes empty upon consuming the last bb at the end of input, it enters an accepting state. Since no non-deterministic choices are needed, LL is a DCFL. Thus, Statement I is TRUE and Statement II is FALSE.

  2. LL($k$) property: For any fixed lookahead kk, a predictive top-down parser cannot decide whether to apply the production for ana^n or anbna^n b^n when the number of aa's exceeds kk, because it cannot see whether bb's will appear after arbitrarily many aa's. Hence, LL is not LL($k$) for any $k$. Thus, Statement III is TRUE.

Therefore, statements I and III only are TRUE, which corresponds to option (C).

Try the question first, then check your work.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

This Context-Free Grammars and PDAs previous year question is Q10 of the GATE CSE 2020 paper. Find more GATE CSE PYQs on Context-Free Grammars and PDAs in Theory of Computation, or browse all GATE CSE PYQs.

Free diagnostic

Where do you stand for GATE?

Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Context-Free Grammars and PDAs PYQs now with no account.

One GATE CSE PYQ every morning

An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.

Context-Free Grammars and PDAs in GATE CSE

Context-Free Grammars and PDAs has 26 GATE CSE PYQs across 17 papers from 2011 to 2026. 9 of them are 1-mark MCQs like this one, and it is the only one in GATE CSE 2020.

How GATE tests Context-Free Grammars and PDAs

More from GATE CSE 2020

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2020 · Q10 · MCQ

Consider the language L = {an n ≥ 0} ∪ {an bn n ≥ 0} and the following statements. I. L is deterministic context-free. II. L is context-free but not deterministic context-free. III. L is not LL(k) for any k. Which of the above statements is/are TRUE?

Topic-wise GATE CS PYQs with verified steps

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.