Question
Consider the language and the following statements.
I. is deterministic context-free.
II. is context-free but not deterministic context-free.
III. is not for any .
Which of the above statements is/are TRUE?
Official answer and solution
- Official answer
- C
- From
- Official GATE 2020 answer key
Solution
Determine the determinism of the language by constructing a DPDA with an endmarker, and test LL(k) grammar feasibility.
Given language: over .
Evaluation of Statements I and II (DCFL property):
- To test if is a deterministic context-free language (DCFL), check if a DPDA with an endmarker can accept by final state:
- Read all 's and push them onto the stack.
- If the endmarker is read immediately (no 's follow), enter an accepting state (accepts ).
- If 's follow, transition to a state that pops one for each read. When the endmarker is reached with an empty stack, enter an accepting state (accepts ).
- Since all transitions are deterministic with the lookahead endmarker , is deterministic context-free (DCFL).
- Thus, Statement I is TRUE and Statement II is FALSE.
Evaluation of Statement III (LL(k) property):
- An parser must decide whether to expand or after reading at most tokens of lookahead.
- If an input string starts with , lookahead of length only sees a sequence of 's (). The parser cannot determine whether the string will terminate as or continue with .
- Since is finite and the length of 's can be arbitrarily large, no grammar can parse .
- Thus, Statement III is TRUE.
Statements I and III only are TRUE.
C
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2020 Computer Science and Information Technology (CS)
- Question
- 20 of 65, printed as CS Q.10
- 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.