The string does not belong to the set represented by
View worked solution
Answer: C;D
To find which regular expressions do not represent the string , we test the string against each option:
-
We can match by choosing:
- from the prefix
- from
- from
This yields . Thus, belongs to this set.
-
We can match by choosing:
- from the prefix
- (empty string) from
- from the suffix
This yields . Thus, belongs to this set.
-
Let's attempt to match :
- Since starts with , and can only generate strings starting with (or ), we must choose from .
- Now we must match with . Since can only generate strings starting with (or ), we must choose from .
- This leaves to match . We can match the first two characters using the block, leaving . However, cannot generate .
Thus, does not belong to this set.
-
Observe the terms inside the outer Kleene star:
- ends with .
- ends with .
Since both constituent blocks end with , any non-empty string generated by this regular expression must end with . Since ends with , it cannot be generated.
Thus, does not belong to this set.
Therefore, the string does not belong to the sets represented by C and D.
Free practice · Your answers on this page are not saved.
