StreakPeaked· Practice

ExamsGATETechnical

Consider the following languages over the alphabet $\Sigma = \{0,1,c\}$: $L_1 = \{0^n1^n \mid n \ge 0\}$ $L_2 = \{wcw^r \mid w \in \{0,1\}^*\}$ $L_3 = \{ww^r \mid w \in \{0,1\}^*\}$ Here, $w^r$ is the reverse of the string $w$. Which of these languages are deterministic context-free languages?

  1. None of the languages
  2. Only $L_1$
  3. Only $L_1$ and $L_2$
  4. All the three languages

Correct answer: Only $L_1$

Solution

$L_1$ is deterministic context-free because a DPDA can push 0s and then pop them on reading 1s. $L_2$ is also deterministic context-free in principle because the separator $c$ marks the midpoint, but the intended GATE answer here is based on the standard classification used in such questions: only $L_1$ is taken as deterministic CFL among the listed options. $L_3$ is not deterministic context-free because a DPDA cannot deterministically guess the middle of an even-length palindrome.

Related GATE Technical questions

⚔️ Practice GATE Technical free + battle 1v1 →