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 21–25 of 41
Which of the following languages are context-free?
Answer: (B)
- : the pairs are nested, with m outside and n inside. Push the a's, push the b's, pop one b for each a, then pop one a for each b. Grammar: . It is a CFL.
- : the pairs cross (the first a's go with the second a's, the first b's with the second b's), which a stack cannot do. Pump : the pumped part touches at most two neighbouring blocks, and the partner of a block (1st with 3rd, 2nd with 4th) is never a neighbour. So pumping changes a block without its partner, or breaks the form . It is not a CFL.
- : push every a, pop two a's for each b, and accept if exactly one a is left. Grammar: . It is a CFL.
Answer: (B)
- : the pairs cross (the first a's go with the second a's, the first b's with the second b's), which a stack cannot do. Pump : the pumped part touches at most two neighbouring blocks, and the partner of a block (1st with 3rd, 2nd with 4th) is never a neighbour. So pumping changes a block without its partner, or breaks the form . It is not a CFL.
- : push every a, pop two a's for each b, and accept if exactly one a is left. Grammar: . It is a CFL.
Answer: (B)
Consider the following languages over the alphabet :
Here is the reverse of the string w. Which of these languages are deterministic Context-free languages?
Here is the reverse of the string w. Which of these languages are deterministic Context-free languages?
Answer: (C)
Let us check each language:
- : the PDA pushes the 0s and pops one for each 1 it is a DCFL.
- : the symbol c shows the middle, so the PDA knows when to begin popping it is a DCFL.
- : the PDA has to guess where the middle is it is a CFL but not a DCFL.
Answer: Only L1 and L2
- : the PDA pushes the 0s and pops one for each 1 it is a DCFL.
- : the symbol c shows the middle, so the PDA knows when to begin popping it is a DCFL.
- : the PDA has to guess where the middle is it is a CFL but not a DCFL.
Answer: Only L1 and L2
Consider the following languages.
Which one of the following statements is FALSE?
Which one of the following statements is FALSE?
Answer: (D)
- is regular, so its complement is regular too. The statement (D) says the complement is context-free but not regular, which is false.
- (A) (with ) is the union of and . A PDA pushes the leading 0s, skips the 1s, and pops one 0 for each trailing 0. It accepts if the stack is not empty at the end (p > r), or if it runs out of 0s to pop while 0s are still left (p < r). It is a CFL. True.
- (B) every string of is in , so , a CFL. True.
- (C) is a CFL, so it is recursive. Recursive languages are closed under complement, so the complement of is recursive (even though it need not be a CFL). True.
Answer: (D)
- (A) (with ) is the union of and . A PDA pushes the leading 0s, skips the 1s, and pops one 0 for each trailing 0. It accepts if the stack is not empty at the end (p > r), or if it runs out of 0s to pop while 0s are still left (p < r). It is a CFL. True.
- (B) every string of is in , so , a CFL. True.
- (C) is a CFL, so it is recursive. Recursive languages are closed under complement, so the complement of is recursive (even though it need not be a CFL). True.
Answer: (D)
Consider the languages L1, L2 and L3 as given below
and
Which of the following statements is NOT TRUE?
and
Which of the following statements is NOT TRUE?
Answer: (C)
Let us check each statement:
- L1 = 0*1* it is regular
- L2 = it is a CFL
- L3 = it needs two comparisons it is not a CFL (but a TM can recognise it)
So the statement "all three languages are context free" is NOT true.
Answer: All the three languages are context free
- L1 = 0*1* it is regular
- L2 = it is a CFL
- L3 = it needs two comparisons it is not a CFL (but a TM can recognise it)
So the statement "all three languages are context free" is NOT true.
Answer: All the three languages are context free
Consider the languages
.
.
.
Which one of the following statements is true?
.
.
.
Which one of the following statements is true?
Answer: (D)
A PDA has one stack, so it can compare one count with another (or with twice another). Each language below has a context-free grammar.
- L1 (): this is or . For : , . For : , with the same T. The union of two CFLs is a CFL.
- L2 (): . This is the standard CFL: push a symbol for each 0, pop one for each 1.
- L3 (): . As a PDA: push one symbol for each 0, pop two for each 1, and accept when exactly one symbol is left.
- L4 (): this is or . For : , . For : , with the same U. This gives or followed by at least one extra 1. The union of two CFLs is a CFL.
So all four languages are context-free. Options (A), (B) and (C) each leave out at least one of them.
Answer: (D)
- L1 (): this is or . For : , . For : , with the same T. The union of two CFLs is a CFL.
- L2 (): . This is the standard CFL: push a symbol for each 0, pop one for each 1.
- L3 (): . As a PDA: push one symbol for each 0, pop two for each 1, and accept when exactly one symbol is left.
- L4 (): this is or . For : , . For : , with the same U. This gives or followed by at least one extra 1. The union of two CFLs is a CFL.
So all four languages are context-free. Options (A), (B) and (C) each leave out at least one of them.
Answer: (D)
Keep practising