Question
Consider the following languages.
Which one of the following is TRUE?
Official answer and solution
- Official answer
- A
- From
- Official GATE 2020 answer key
Solution
Demonstrate that L1 can be simplified to a regular expression and L2 is generated by a context-free grammar.
Analysis of :
- Notice that is non-empty (). In particular, can be chosen to be a single symbol: or .
- If : the pattern becomes , where .
- If : the pattern becomes , where .
- Any string that matches with also matches either or by taking the first and last bits of .
- Thus, .
- Since can be expressed by a regular expression, is regular.
Analysis of :
- contains even-length strings where the first half differs from the second half in at least one position .
- That is, for some , the string has the form or with and .
- This language can be generated by the following context-free grammar:
- Here generates strings where the middle character is , and generates strings where the middle character is . produces an even-length string whose first half has at the same relative position where the second half has .
- Thus, is context-free (though non-deterministic).
Therefore, is regular and is context-free.
Final answer
A
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2020 Computer Science and Information Technology (CS)
- Question
- 42 of 65, printed as CS Q.32
- 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.