CSci 151: Foundations of computer science II
Home Syllabus Assignments Tests

Review A: Regular expressions & automata: Questions

A.1.1.

Write a regular expression for each of the following concepts.

a. strings starting with a digit
b. strings containing only alphabetic letters
A.1.2.

Write a regular expression for each of the following concepts.

a. strings containing only alphabetic letters and that start with the letter c
b. strings that containing only digits, but which don't start with 0
A.1.3.

Write a regular expression that describes strings containing the lower-case letter e followed by a digit, with possibly some intervening spaces. Examples include 3e8, the  100K, and e2, but not e-5.

A.1.4.

Write a regular expression that describes all words of lower-case letters that begin with w and contain an r. Examples include weird, word, wrong, and wear, but not awkward, war-weary, or www.hendrix.edu. (The latter two are bad because they contain characters that are not lower-case letters.)

A.2.1.

Design a finite automaton that accepts strings of a's and b's that end with two a's.

A.2.2.

Design a finite automaton that accepts strings of a's and b's that begin and end with the same letter.

A.2.3.

Design a finite automaton that accepts strings of a's and b's that include the substring abaa.

Review A: Regular expressions & automata: Solutions

A.1.1.
a. [0-9].*
b. [a-z]*
A.1.2.
a. c[a-zA-Z]*
b. [1-9][0-9]*
A.1.3.
.*e *[0-9].* (There is a space between the e and the asterisk.)
A.1.4.
w[a-z]*r[a-z]*
A.2.1.
A.2.2.
A.2.3.