Consider the following languages.
Which of the following are CORRECT?
- is context free but not regular
- is not context free
- is not context free but recursive
- is deterministic context free
View worked solution
Answer: D
Let us analyze each language and the corresponding statements:
-
Language :
By Parikh's Theorem, any context-free language over a unary alphabet (single-letter alphabet) must be regular. Since the set of prime numbers does not form an arithmetic progression, is not regular. Consequently, cannot be context-free either.
Therefore, Statement I (" is context free but not regular") is incorrect. -
Language :
In , the number of 's is independent of 's and 's, and we only need to match the number of 's to twice the number of 's. This can be easily done using a single stack (pushing two symbols for every and popping one for every ).
We can write a Context-Free Grammar (CFG) for : Since is context-free, Statement II (" is not context free") is incorrect. -
Language :
requires matching three counts simultaneously ( 's, 's, and 's), which cannot be done with a single stack. Thus, is not context-free (can be formally proven using the pumping lemma for CFLs). However, it is easily decidable by a Turing machine, meaning it is a recursive language.
Therefore, Statement III (" is not context free but recursive") is correct. -
Language :
This is a standard deterministic context-free language (DCFL) because we can construct a Deterministic Pushdown Automaton (DPDA) that pushes 's onto the stack and pops them upon reading 's.
Therefore, Statement IV (" is deterministic context free") is correct.
Since only statements III and IV are correct, the correct option is D.
Free practice · Your answers on this page are not saved.
