Question
Consider the following languages:
Note that is the reversal of the string . Which of the following is/are TRUE?
Official answer and solution
- Official answer
- A, B and C
- From
- Official GATE 2022 answer key
Since every regular language is also context-free, both (A), (B), and (C) are mathematically true and all three are credited in the official key.
Solution
Analyze string membership and construct regular expressions for languages and .
-
For :
Setting , . Since is any arbitrary string in , setting allows to generate every possible string in . Thus , which is a regular language.
(Even if were required, any string starting and ending with 'a' belongs to by setting , giving , which is also regular). -
For :
Since , . Let :- If , then , producing strings of the form where .
- If , then , producing strings of the form where .
Any string that starts and ends with the same character and has length at least 3 can be factored into with . Conversely, any string in has length and starts and ends with the same character. Thus , which is regular.
Since and are both regular, they are also context-free (every regular language is context-free). Therefore, Statement (A), Statement (B), and Statement (C) are all TRUE.
Options (A), (B), (C)
Assuming the condition requires a pushdown automaton to verify arbitrary matching prefixes and suffixes, failing to notice that choosing suffices.
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2022 Computer Science and Information Technology (CS)
- Question
- 47 of 65
- 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.