Consider the following languages.
Which one of the following is TRUE?
View worked solution
Answer: A
To determine the classes of the given languages, we analyze and individually:
Analysis of :
The language is defined as . Let end with a single symbol , so we can write where . Substituting this back:
Let and . Since , we must have . Thus, any string in can be simplified to have a single-symbol matching marker at the end of each segment. This allows us to write as the union of two regular languages:
This corresponds to the regular expression . Hence, is regular.
Analysis of :
represents the set of even-length strings where the first half is not equal to the second half. This means there is at least one position where the symbol in the first half differs from the symbol in the second half.
We can generate using the following Context-Free Grammar (CFG):
Here, generates odd-length strings with in the middle, and generates odd-length strings with in the middle. The concatenation ensures that the mismatch occurs at the exact corresponding index in both halves. Thus, is context-free (but not regular).
Free practice · Your answers on this page are not saved.
