CMPS 260 Spring 2020
Homework #4: Regular Expressions
Due: Noon, Monday April 6

Where r is a regular expression, L(r) denotes the language (i.e., set of strings) described by r.

1. Present a list containing precisely those strings of length six that are members of L( (ab + c)*a ). Arrange the strings in alphabetical order.


2. Present a list containing precisely those strings of length five or less that are members of

L( (ba + a)*bb(a + ab)* ).

Arrange the strings from shortest to longest; within each group of strings having the same length, put them in alphabetical order.


3. Present a regular expression describing LR (the reverse of L), where L is the language described by the regular expression

(abb + b)*b(ba + a)*

4. Present a regular expression r such that the language that it describes, L(r), is the complement of the language L, where

L = { a2n+1 bm  |  n≥0 ∧ m≥1 }.

L contains precisely those strings having an odd number of a's followed by at least one b and is described by the regular expression (aa)*abb*.


5. Present a regular expression describing the language over {0,1} containing precisely those strings having exactly two occurrences of 11 and no occurrences of 111. As an aid, provided is the regular expression

(0 + 10)*(1 + λ)

describing the language over {0,1} containing precisely those strings having no occurrences of 11.

For a small bonus, present a second regular expression describing the language as described above, but allowing for the occurrence of 111. Such an occurrence counts as two occurrences of 11 (that happen to overlap).


6. Present a regular expression describing the language

L = { w ∈ {a,b}*  |  |w| mod 4 = 2}

That is, L contains precisely those strings over {a,b} having length divisible by two but not divisible by four.


7. Use the algorithm described in Section 3.2 of Linz to produce an NFA that accepts the language described by the regular expression

c(a + aba)*bb  +  abc*

Within reason, you can take a few shortcuts. For example, the sub-NFA accepting aba can be the obvious 4-state NFA rather than the 6-state NFA that following the algorithm literally would produce. However, your final result should make it clear that you cobbled together sub-NFA's corresponding to sub-expressions within the given regular expression in the way described by the algorithm.