Question
Consider the following languages.
Which of the following are CORRECT?
I. is context-free but not regular.
II. is not context-free.
III. is not context-free but recursive.
IV. is deterministic context-free.
Official answer and solution
- Official answer
- D
- From
- Official GATE 2017 answer key
Solution
Classify each given language within the Chomsky hierarchy.
Evaluate the four languages:
- :
By Parikh's theorem, any context-free language over a single-letter alphabet is regular. Since is not regular (primes do not form an arithmetic progression), cannot be context-free. Thus, Statement I is INCORRECT. - :
. Since is regular and is a deterministic context-free language, their concatenation is a context-free language. Thus, Statement II (which asserts is not context-free) is INCORRECT. - :
Requires matching the counts of three separate symbol blocks () simultaneously. By the pumping lemma for CFLs, is not context-free. However, a multi-track Turing machine can easily compare the counts, so is recursive (decidable). Thus, Statement III is CORRECT. - :
A deterministic pushdown automaton (DPDA) can push each '' onto the stack and pop an '' for each '', accepting when the input and stack are both empty. Thus, is a deterministic context-free language (DCFL). Thus, Statement IV is CORRECT.
Statements III and IV only are correct, which corresponds to option D.
D
Assuming unary languages can be context-free without being regular; by Parikh's theorem, every unary CFL is regular.
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2017 Computer Science and Information Technology (CS) Session 2
- Question
- 40 of 65, printed as CS Q.40
- 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.