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 6–10 of 41
Consider the following languages:
Which of the following statements is/are FALSE?
Which of the following statements is/are FALSE?
One or more options are correct.
Answer: (B), (C), (D)
Facts about the three languages:
- and are deterministic CFLs: a DPDA matches the a's with the b's and then skips the c's (for ), or skips the a's and matches the b's with the c's (for ).
- is not context-free. Intersect with the regular language to get and pump . The pumped part can touch at most two neighbouring blocks, but the matching blocks (1st with 3rd, 2nd with 4th) are never neighbours, so one block changes without its partner and the form breaks.
- The complement of is context-free. It is the odd-length strings (regular) together with the even-length strings that have an a in one half and a b exactly half the length later, or the other way round. These are generated by : the centres of the odd strings A and B are exactly half the total length apart.
Now the statements:
- (A) is true: is not a CFL, and are DCFLs.
- (B) is false: is context-free.
- (C) is false: (a's equal b's and b's equal c's), which is not context-free, since pumping cannot keep all three counts equal.
- (D) is false: the complement of is context-free.
Answer: (B), (C), (D)
- and are deterministic CFLs: a DPDA matches the a's with the b's and then skips the c's (for ), or skips the a's and matches the b's with the c's (for ).
- is not context-free. Intersect with the regular language to get and pump . The pumped part can touch at most two neighbouring blocks, but the matching blocks (1st with 3rd, 2nd with 4th) are never neighbours, so one block changes without its partner and the form breaks.
- The complement of is context-free. It is the odd-length strings (regular) together with the even-length strings that have an a in one half and a b exactly half the length later, or the other way round. These are generated by : the centres of the odd strings A and B are exactly half the total length apart.
Now the statements:
- (A) is true: is not a CFL, and are DCFLs.
- (B) is false: is context-free.
- (C) is false: (a's equal b's and b's equal c's), which is not context-free, since pumping cannot keep all three counts equal.
- (D) is false: the complement of is context-free.
Answer: (B), (C), (D)
Suppose that is a regular language and is a context-free language. Which one of the following languages is NOT necessarily context-free?
Answer: (C)
Let be regular and be a CFL.
- The languages , and are always CFL, by closure properties.
- The language uses the complement of a CFL, and that need not be a CFL. For example, if , the result is only .
Answer:
- The languages , and are always CFL, by closure properties.
- The language uses the complement of a CFL, and that need not be a CFL. For example, if , the result is only .
Answer:
Let be a regular language and be a context-free language. Which of the following languages is/are context-free?
One or more options are correct.
Answer: (B), (C), (D)
Facts used: CFLs are closed under union and under intersection with a regular language. They are not closed under complement.
- (A) : not always a CFL. Take (regular); the expression becomes , and a CFL's complement need not be a CFL. For example, is a CFL but its complement is not.
- (B) (De Morgan). This is a regular language intersected with a CFL, so it is a CFL. True.
- (C) , so , which is regular and so a CFL. True.
- (D) , a CFL. True.
Answer: (B), (C), (D)
- (A) : not always a CFL. Take (regular); the expression becomes , and a CFL's complement need not be a CFL. For example, is a CFL but its complement is not.
- (B) (De Morgan). This is a regular language intersected with a CFL, so it is a CFL. True.
- (C) , so , which is regular and so a CFL. True.
- (D) , a CFL. True.
Answer: (B), (C), (D)
For a string , we define to be the reverse of . For example, if then .
Which of the following languages is/are context-free?
Which of the following languages is/are context-free?
One or more options are correct.
Answer: (B), (C), (D)
- (A) : the pair and the pair cross, since x sits between w and but comes after . A stack matches only nested pairs, so this is not a CFL. Proof sketch with the pumping lemma (length p) on (w = , x = ):
Any member of the form (all at least 1) has w starting with 0 and x starting with 1, and w, carry equal numbers of 0/1 changes, while the string has only three. This forces either ( and ) or ( and ). A string is never a member.
Since , the pumped part touches at most two neighbouring blocks. In blocks 1 and 2: if it adds a's, pump up (then , not a member); otherwise it only changes the 1-block, so pump down (then and , not a member). In blocks 3 and 4 it is the mirror image: if it adds 1's (so , with ) pump up; otherwise pump down. In blocks 2 and 3: if it changes both blocks, pump up; if only one, pump down. Every case leaves the language.
- (B) : two even palindromes one after the other, . It is a CFL.
- (C) : take . Then x is any string, so the language is all of , which is regular and so a CFL.
- (D) : this is , an even palindrome, with the pairs nested, . It is a CFL.
Answer: (B), (C), (D)
Any member of the form (all at least 1) has w starting with 0 and x starting with 1, and w, carry equal numbers of 0/1 changes, while the string has only three. This forces either ( and ) or ( and ). A string is never a member.
Since , the pumped part touches at most two neighbouring blocks. In blocks 1 and 2: if it adds a's, pump up (then , not a member); otherwise it only changes the 1-block, so pump down (then and , not a member). In blocks 3 and 4 it is the mirror image: if it adds 1's (so , with ) pump up; otherwise pump down. In blocks 2 and 3: if it changes both blocks, pump up; if only one, pump down. Every case leaves the language.
- (B) : two even palindromes one after the other, . It is a CFL.
- (C) : take . Then x is any string, so the language is all of , which is regular and so a CFL.
- (D) : this is , an even palindrome, with the pairs nested, . It is a CFL.
Answer: (B), (C), (D)
Consider the language and the following statements.
I. L is deterministic context-free.
II. L is context-free but not deterministic context-free.
III. L is not LL(k) for any k.
Which of the above statements is/are TRUE?
I. L is deterministic context-free.
II. L is context-free but not deterministic context-free.
III. L is not LL(k) for any k.
Which of the above statements is/are TRUE?
Answer: (C)
Statements I and II. A DPDA pushes an a for each a it reads and accepts if the input ends there (the string is ). When it reads the first b, it starts popping one a per b, and accepts if the stack is empty at the end of the input. It never has to guess, so is a deterministic CFL. So I is true and II is false.
Statement III. For a large n, the inputs and have the same first n symbols. An LL(k) parser picks each production from the next k symbols only. Until it is within k symbols of the end of the a's, it sees only a's and so must make the same choices for both inputs, whatever grammar is used. It would then have about n pending symbols which must be matched with n b's for one input and all erased for the other, and k symbols of lookahead cannot make that choice for all of them. So is not LL(k) for any k. III is true.
Answer: (C)
Statement III. For a large n, the inputs and have the same first n symbols. An LL(k) parser picks each production from the next k symbols only. Until it is within k symbols of the end of the a's, it sees only a's and so must make the same choices for both inputs, whatever grammar is used. It would then have about n pending symbols which must be matched with n b's for one input and all erased for the other, and k symbols of lookahead cannot make that choice for all of them. So is not LL(k) for any k. III is true.
Answer: (C)
Keep practising