Let be the set of all strings over the alphabet , including the empty string , that do not contain as a substring. Which one of the following regular expressions denotes exactly ?
Show solution
Solution MCQ · 1 mark · −⅓ if wrong
Answer: (A)
Method: describe the structure of the language, then test each option on short witnesses.
In a string with no , every is followed by an unless it is the last symbol. So the string is a sequence of blocks or , optionally followed by one final : . Conversely, gluing such blocks never puts two s together, because each block ends in .
Test the others with one string each:
| Option | Witness | Why it fails |
|---|---|---|
| (b) | in , but every string of (b) is empty or ends in | |
| (c) | generated as , but contains | |
| (d) | generated as , but contains |
Trap. Options (c) and (d) look like harmless rearrangements of (a), but moving the optional to the wrong side of a block lets it touch another . Checking one string per option, especially strings at the boundaries (empty, ending in , starting with ), exposes this quickly.
What was tested: building a regular expression from a forbidden-substring condition and checking candidates with witness strings in both directions.
Copied. Paste it into the new chat.Too long to send. Copy the question and solution by hand.