COT3100.01, Fall 2000
S. Lang
Solution Key to Assignment #6 (40 pts.)
11/30/2000
Let
a
,
b
,
c
denote distinct symbols for the following questions:
1.
Give a regular expression for each of the following languages (no proof is required but brief
explanations are encouraged):
(a)
The set of strings over {
a
,
b
} that contain exactly two occurrences of symbol
a
and at least one
occurrence of symbol
b
.
bb
*
ab
*
ab
* +
b
*
abb
*
ab
* +
b
*
ab
*
abb
*.
Explanation (FYI): The first term
bb
*
ab
*
ab
* represents those strings that contain two
a
’s with at
least one
b
before the first
a
; similarly, the second term
b
*
abb
*
ab
* represents those strings that
contain two
a
’s with at least one
b
between the two
a
’s; and the third term
b
*
ab
*
abb
* represents
those strings that contain two
a
’s with at least one
b
after the second
a
.
(b)
The set of strings over {
a
,
b
} that contain the substring
aa
but do not contain the substring
bb
.
(
a
*(
baa
*)* +
a
*(
baa
*)*
b
)
aa
(
a
*(
baa
*)* +
a
*(
baa
*)*
b
).
Explanation (FYI): The expression (
baa
*)* is used to ensure each
b
(if any) is followed by at least
one
a
before the next
b
; therefore guaranteeing no occurrences of two consecutive
b
’s.
Thus, the
term
a
*(
baa
*)* represents strings with possible leading
a
’s but no occurrences of substring
bb
; the
other term
a
*(
baa
*)*
b
covers those strings with an ending single
b
.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview.
Sign up
to
access the rest of the document.
 Fall '09
 Mathematical Induction, Recursion, Natural number, Formal language, A*

Click to edit the document details