Question
Suppose that is a regular language and is a context-free language. Which one of the following languages is NOT necessarily context-free?
Official answer and solution
- Official answer
- C
- From
- Official GATE 2021 answer key
Solution
Apply closure properties of context-free languages under set operations.
Let be regular and be context-free (CFL). We evaluate each option:
- Option A: . The intersection of a regular language and a CFL is always a CFL. (True)
- Option B: . Because is regular, its complement is also regular. The intersection of a CFL with a regular language is always a CFL. (True)
- Option D: . The union of two CFLs (noting that every regular language is a CFL) is always a CFL. (True)
Now consider Option C: . CFLs are not closed under complementation. If we choose (which is regular), then .
Since the complement of a CFL is not necessarily context-free, is NOT necessarily context-free. Hence, option C is the correct answer.
C
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2021 Computer Science and Information Technology (CS, Set-1)
- Question
- 11 of 65, printed as CS Q.1
- 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.