Regular expressions short exercise
Find a regular expression for each of the following languages.
In each case, let the alphabet be {a, b}.
- Strings that have neither aa nor bb as substrings.
- Strings that have an odd number of as and an
even number of bs.
(Remember that 0 is an even number.)
- Strings that have both ab and ba as substrings.
(Make sure that your RE will accept a string like aaaabaaa;
ab and ba are both substrings, even though they overlap.)
These exercises are taken from Lewis and Papadimitriou,
Elements of the Theory of Computation, Prentice Hall, 1998.
There's a copy in the CSCI 335 library.
Last modified: Tue Mar 24 17:01:44 CDT 2009