CS 340 - Assignment 1

Due: Monday, September 17th by 11:59 PM

Regular Expressions and Finite Automata

Part 1 - Regular Expressions

Please save your answers to the following regular expression problems in a plain text file.

These regular expression problems are also available as a RegeXeX problem set at the following URL:

http://faculty.ycp.edu/~dhovemey/fall2007/cs340/assign/assign1regex

If you use RegeXeX to work on these problems, save your solutions in a text file.  You will not submit your solutions directly through RegeXeX.

Problem 1.

Define a regular expression that generates the following language over the alphabet {a, b}:

a
aaab
aaabaab
aaabaabaab
...etc...

Problem 2.

Define a regular expression that generates the language over the alphabet {a, b} of all strings containing at most two occurrences of a.

For example, the following strings are members of the language:

ε
a
ba
aba
bbaa
aba

The following strings are not members of the language:

aaa
baabaa
baaaa

Problem 3.

Define a regular expression that generates the language over the alphabet {a, b} of all strings containing an odd number of b's.

For example, the following strings are members of the language:

b
ab
aba
bbabaa

The following strings are not members of the language:

ε
abb
bababb

Problem 4.

Define a regular expression that generates the language over the alphabet {a, b, c} of all strings not containing the substring ba.

For example, the following strings are members of the language:

ε
a
ab
bb
bc
cbc
abbb

The following strings are not members of the language:

ba
baba
aba
ccaabac

Problem 5.

Define a regular expression that generates the language over the alphabet {a, b} of all strings in which the first occurrence of the symbol a (if it occurs in the string at all) is followed by at least one additional a.

For example, the following strings are members of the language:

ε
b
bb
aa
baaba
aaabaa

The following strings are not members of the language:

a
bba
babaa

Part 2 - Finite Automata

For each of the following finite automata problems, use JFLAP to construct the automaton, saving it in a JFLAP file (which will have a .jff file extension).  Please use the filenames prob6.jff, prob7.jff, etc.

If the problem asks for a deterministic finite automaton, make sure that your automaton does not have any nondeterministic states.  (In JFLAP, use the Test->Highlight Nondeterminism menu option.)

Problem 6.

Construct a deterministic finite automaton that recognizes the language over the alphabet {a, b} containing all strings with an odd number of b's.  [See problem 3 for example strings that should be accepted or rejected.]

Problem 7.

Construct a deterministic finite automaton that recognizes the language over the alphabet {a, b} containing all strings with an even number of a's and an odd number of b's.

For example, the following strings should be accepted by the automaton:

b
aab
aba
baa
bbabaaa

The following strings should be rejected by the automaton:

ε
ab
aabb
abab

Problem 8.

Construct a finite automaton (deterministic or nondeterministic) that recognizes the language over the alphabet {a, b} generated by the regular expression:

(a|ab|abb|abbb)*

For example, the following strings should be accepted by the automaton:

ε
a
aa
aab
abba
abbabbab

The following strings should be rejected by the automaton:

ba
abbbb

Problem 9.

Construct a finite automaton (deterministic or nondeterministic) that recognizes the language over the alphabet {a, b, c} of all strings not containing the substring ba.  [See problem 4 for strings that should be accepted and rejected.]

Problem 10.

Construct a deterministic finite automaton that recognizes the language over the alphabet {a, b} of all strings where the number of a's in the string is a multiple of 3.

For example, the following strings should be accepted by the automaton:

ε
bb
ababa
aaba
aaababaa

The following strings should be rejected by the automaton:

a
aba
baaabaa

Submitting

Save the text file containing your solutions to problems 1-5, and the JFLAP files containing your solutions to problems 6-10, in a single zip file.

Submit your zip file online via the Marmoset server at the URL

https://camel.ycp.edu:8443/

Click the submit link CS 340, project 1.