Skip to content
Official PYQ · 2014

GATE CS 2014 Set 3 Q36 — Context-free Grammars and Push-down Automata

Explain with AI

Consider the following languages over the alphabet ∑={0,1,c}\sum = \{0, 1, c\}

L1={0n1n∣n≥0}L_1 = \left\{0^n1^n\mid n \geq 0\right\}

L2={wcwr∣w∈{0,1}∗}L_2 = \left\{wcw^r \mid w \in \{0,1\}^*\right\}

L3={wwr∣w∈{0,1}∗}L_3 = \left\{ww^r \mid w \in \{0,1\}^*\right\}

Here, wrw^r is the reverse of the string ww. Which of these languages are deterministic Context-free languages?

Choose one option
View worked solution

Answer: C

A language is a Deterministic Context-Free Language (DCFL) if and only if it can be accepted by a Deterministic Pushdown Automaton (DPDA).

Let's analyze each language individually:

  1. Language L1={0n1n∣n≥0}L_1 = \{0^n 1^n \mid n \geq 0\}:

    A DPDA can easily recognize this language. We push all incoming 00s onto the stack. When the first 11 is encountered, the automaton deterministically switches to a popping state, matching each subsequent 11 with a 00 from the stack. Since there is no ambiguity about when to start popping, L1L_1 is a DCFL.

  2. Language L2={wcwr∣w∈{0,1}∗}L_2 = \{w c w^r \mid w \in \{0,1\}^*\}:

    The presence of the marker symbol 'cc' clearly demarcates the boundary between ww and its reverse wrw^r. A DPDA can push the characters of ww onto the stack, and upon reading 'cc', deterministically switch to matching the remaining input with the stack symbols. Because the transition point is deterministic, L2L_2 is a DCFL.

  3. Language L3={wwr∣w∈{0,1}∗}L_3 = \{w w^r \mid w \in \{0,1\}^*\}:

    Unlike L2L_2, there is no marker to indicate where ww ends and wrw^r begins (for example, in the string 01100110, the split is not marked). A pushdown automaton must non-deterministically guess the midpoint to transition from pushing to popping. Thus, L3L_3 requires a Non-deterministic Pushdown Automaton (NPDA) and is not a DCFL (it is a CFL but not a DCFL).

Therefore, only L1L_1 and L2L_2 are deterministic Context-free languages.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Context-free Grammars and Push-down Automata questions