Which regular expression represents the set of all strings over that do NOT contain "rt" as a substring?
Which regular expression represents the set of all strings over that do NOT contain "rt" as a substring?
Multiple Choice Options
- A
- B
- C
- D✓ Correct Option
Detailed Technical Solution & Explanation
A string contains the substring "rt" if any 'r' is followed by a 't'. To prevent "rt" from appearing anywhere, all 't's must appear before all 'r's (i.e., once an 'r' appears, no 't' can ever follow). This is precisely generated by the regular expression **** (any number of 't's followed by any number of 'r's).
Option Analysis:
•
Option A (): Explicitly contains 'rt'.
•
Option B (): Generating strings like contains "rt" internally.
•
Option C (): Generates when .
•
Option D (): Correct; guarantees all 't's precede 'r's, completely preventing "rt".
Reference: Mock Test 05View Chapter 10 Official Syllabus Blueprint →