Question

Consider the following languages over the alphabet Σ={0,1,c}\Sigma = \{0, 1, c\}:

L1={0n1n∣n≥0}L_1 = \{0^n 1^n \mid n \ge 0\}
L2={wcwr∣w∈{0,1}∗}L_2 = \{w c w^r \mid w \in \{0, 1\}^*\}
L3={wwr∣w∈{0,1}∗}L_3 = \{w w^r \mid w \in \{0, 1\}^*\}

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

Choose one option
Official answer and solution
Official answer
C
From
Official GATE 2014 answer key

Solution

Determine whether each language can be accepted by a Deterministic Pushdown Automaton (DPDA).

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

    • A DPDA starts in a state where it pushes each 0 onto the stack.
    • On seeing the first 1, it deterministically switches state and pops a 0 for each 1.
    • If the input and stack empty simultaneously, the string is accepted.
    • Every move is uniquely determined by the current state, input symbol, and top of the stack.
    • Thus, L1L_1 is accepted by a DPDA, so L1L_1 is a DCFL.
  2. Language L2={wcwr∣w∈{0,1}∗}L_2 = \{w c w^r \mid w \in \{0, 1\}^*\}:

    • The distinct symbol cc serves as an explicit center marker separating ww and wrw^r.
    • A DPDA pushes symbols of ww onto the stack until it reads cc.
    • Upon seeing cc, it switches deterministically to a popping state and verifies that each subsequent symbol matches the stack top.
    • No non-deterministic choice is required.
    • Thus, L2L_2 is accepted by a DPDA, so L2L_2 is a DCFL.
  3. Language L3={wwr∣w∈{0,1}∗}L_3 = \{w w^r \mid w \in \{0, 1\}^*\}:

    • Without a center marker, an automaton cannot determine where ww ends and wrw^r begins without non-deterministically guessing the midpoint of the string.
    • It is a standard result in formal language theory that wwrw w^r is a non-deterministic Context-Free Language but NOT a Deterministic Context-Free Language (DCFL).
  4. Therefore, only L1L_1 and L2L_2 are deterministic Context-free languages (option C).

Final answer

C

Common trap

Assuming all context-free palindromes are DCFLs, overlooking the necessity of the center marker c for deterministic recognition.

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2014 Computer Science and Information Technology (CS) Session 3
Question
46 of 65, printed as CS Q.36
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.