Question
Consider the following languages over the alphabet :
Here, is the reverse of the string . Which of these languages are deterministic Context-free languages?
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).
-
Language :
- A DPDA starts in a state where it pushes each
0onto the stack. - On seeing the first
1, it deterministically switches state and pops a0for each1. - 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, is accepted by a DPDA, so is a DCFL.
- A DPDA starts in a state where it pushes each
-
Language :
- The distinct symbol serves as an explicit center marker separating and .
- A DPDA pushes symbols of onto the stack until it reads .
- Upon seeing , it switches deterministically to a popping state and verifies that each subsequent symbol matches the stack top.
- No non-deterministic choice is required.
- Thus, is accepted by a DPDA, so is a DCFL.
-
Language :
- Without a center marker, an automaton cannot determine where ends and begins without non-deterministically guessing the midpoint of the string.
- It is a standard result in formal language theory that is a non-deterministic Context-Free Language but NOT a Deterministic Context-Free Language (DCFL).
-
Therefore, only and are deterministic Context-free languages (option C).
C
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.