patternMinor
Regular expression for words containing single 1 and even number of 0s
Viewed 0 times
expressioncontainingnumberwordsregularsingleforandeven
Problem
What would be a regular expression for the language of words containing a single 1 and an even number of 0s?
Solution
If a word contains exactly one 1 and an even number of zeroes, then we can decompose it in one of two different ways:
You take it from here.
- An even number of 0s, followed by 1, followed by an even number of 0s.
- An odd number of 0s, followed by 1, followed by an odd number of 0s.
You take it from here.
Context
StackExchange Computer Science Q#101603, answer score: 3
Revisions (0)
No revisions yet.