Question
Which of the following languages is/are regular?
, is the reverse of string
Official answer and solution
- Official answer
- A
- From
- Official GATE 2015 answer key
Solution
Analyze each language using closure properties and finite-state expressibility.
- Analyze :
Since , we can choose to be a single symbol ( or ).
- If , then , producing strings of the form where .
- If , then , producing strings of the form where .
Conversely, any string in that starts and ends with the same symbol and has length can be written as by setting to the first symbol (so ).
Thus, is simply the regular language:
Since it is expressed by a regular expression, is regular.
- Analyze :
Recognizing whether requires infinite memory to compare the count of 's and 's. By the Pumping Lemma, is not regular.
- Analyze :
This language is generated directly by the regular expression , so is regular.
Thus, and only are regular (option A).
Final answer
A
Common trap
Assuming is non-regular like palindromes, overlooking that allows absorbing all intermediate characters while keeping .
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2015 Computer Science and Information Technology (CS) Session 2
- Question
- 61 of 65, printed as CS Q.51
- 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.