Context Free Language · Theory of Computation
41 questions · asked in 24 of 27 years (2000–2026)
MCQ 36 · MSQ 51-mark 23 · 2-mark 18
2000Questions per year2026
Questions 31–35 of 41
Let L be a context-free language and M a regular language. Then the language is
Answer: (D)
CFLs are closed under intersection with a regular language. Take a PDA for and a DFA for . Build a PDA whose states are pairs (state of , state of ). It runs both machines on the same input and keeps the stack of . It accepts when both are in accepting states. So is always context-free, which is (D).
The other options fail with examples, with :
- (A) and (C): take and . Then , which is a CFL but neither regular nor a deterministic CFL.
- (B): take . Then , which is regular.
Answer: (D)
The other options fail with examples, with :
- (A) and (C): take and . Then , which is a CFL but neither regular nor a deterministic CFL.
- (B): take . Then , which is regular.
Answer: (D)
Let
Which of these languages are NOT context free?
Which of these languages are NOT context free?
Answer: (D)
Rewrite each language.
- : . A grammar is , . So is context-free.
- : with , strings are with . It needs two comparisons at once: first 0s with 1s, and last 0s with the first block.
- : strings are for , which is the standard non-CFL.
Why is not context-free (pumping lemma): take and split it as with and .
- If does not touch the last block of 0s, pump down (). The first 0s and the 1s are reduced, and the last block still has zeros. For the string to stay in , the first 0s and the 1s would need to stay equal and at least , which cannot happen when something was removed.
- Otherwise lies within the 1s and the last 0s. Pump up (). Either the 1s increase and no longer equal the first 0s, or the last 0s increase beyond .
So and are not context-free, while is.
Answer: (D)
- : . A grammar is , . So is context-free.
- : with , strings are with . It needs two comparisons at once: first 0s with 1s, and last 0s with the first block.
- : strings are for , which is the standard non-CFL.
Why is not context-free (pumping lemma): take and split it as with and .
- If does not touch the last block of 0s, pump down (). The first 0s and the 1s are reduced, and the last block still has zeros. For the string to stay in , the first 0s and the 1s would need to stay equal and at least , which cannot happen when something was removed.
- Otherwise lies within the 1s and the last 0s. Pump up (). Either the 1s increase and no longer equal the first 0s, or the last 0s increase beyond .
So and are not context-free, while is.
Answer: (D)
The language is
Answer: (A)
The language is regular. In fact, it is finite. The value of is limited, so only a finite set of strings meets the given conditions. We can then build a finite automaton for these strings easily.
Let L be a regular language and M be a context-free language, both over the alphabet . Let and denote the complements of L and M respectively. Which of the following statements about the language is TRUE?
Answer: (D)
Let us first choose . Then we get and so .
The complement of a CFL need not be a CFL, because CFLs are not closed under complement.
So, (A) and (B) are false.
Now choose . Then we get and . This is regular, so (C) is also false.
So the answer is (D).
Consider the languages:
,where # is a special symbol
Which one of the following is TRUE?
,where # is a special symbol
Which one of the following is TRUE?
Answer: (B)
- : the symbol marks the middle. A DPDA pushes the symbols of until it sees , then pops one symbol for each input symbol while matching . No guessing is needed, so is a deterministic CFL.
- : there is no marker, so the machine must guess where the middle is. This needs nondeterminism. It is a CFL but not a deterministic CFL, so (A) is false.
- : a stack gives the reverse of , not in the same order, so it cannot be matched. is not context-free at all (pumping lemma on ). So (C) and (D) are false.
Answer: (B)
- : there is no marker, so the machine must guess where the middle is. This needs nondeterminism. It is a CFL but not a deterministic CFL, so (A) is false.
- : a stack gives the reverse of , not in the same order, so it cannot be matched. is not context-free at all (pumping lemma on ). So (C) and (D) are false.
Answer: (B)
Keep practising