Which one of the following regular expressions over {0,1} denotes the set of…
1997
Which one of the following regular expressions over {0,1} denotes the set of all strings not containing 100 as a substring?
Answer: D. 0*(10+1)* — Concept: A regular expression avoids a forbidden substring like 100 only if its own construction rules out the exact adjacency that forms it — here, a 1…
- A.
0* (1+0)*
- B.
0*1010*
- C.
0*1*01*
- D.
0*(10+1)*
Attempted by 39 students.
Show answer & explanation
Correct answer: D
Concept: A regular expression avoids a forbidden substring like 100 only if its own construction rules out the exact adjacency that forms it — here, a 1 immediately followed by two consecutive 0s. The standard technique is to build every generated string only from fixed "blocks" that individually can never create that adjacency, however the blocks are chained together.
Application:
In
0*(10+1)*, the leading0*produces any number of 0s before any 1 has occurred, so this part alone can never contain100.The remainder,
(10+1)*, is built by repeatedly choosing one of two blocks,10or1, and concatenating the chosen blocks in any order.Concrete trace: choosing the blocks
1,10,1gives1+10+1=1101. Checking every length-3 window of1101—110and101— neither equals100.Conversely, take any string that avoids
100: strip its leading run of 0s, if any. The remainder starts with a1(or is empty), so every0left in it is preceded by a1, and no such0can itself be followed by another0— that would already place100at that exact spot. So scanning the remainder left to right, every1is followed either by a single0(forming the block10) or directly by the next1(forming the block1) — or, if that 1 is the remainder’s very last symbol, it stands alone as a final block 1 — consuming the whole remainder into1/10blocks. This shows every100-avoiding string is produced by0*(10+1)*, matching the completeness half of the "denotes exactly this set" claim.
Cross-check: To ever produce 100, some 0 would have to be immediately followed by another 0 right after a 1. But the only zero-producing step inside (10+1)* is the single 0 tied to its own 10 block, and the symbol right after it is always either the 1 that starts the next block or the end of the string — never a second 0. So 100 can never occur, confirming this expression denotes exactly the required language: all strings over {0,1} that avoid 100 as a substring.
Explore the full course: Iocl Engineers Officers Grade A Paper 2