Professional Documents
Culture Documents
10 Problem Set 1
10 Problem Set 1
10 Problem Set 1
Problem 1
a. Construct a DFA that accepts all base 3 numbers (consisting of digits 0, 1, and 2)
which are multiples of 4.
b. Construct a DFA that accepts all strings which are valid C comments, where */ may
appear within the body of the comment, provided it appears inside double quotes.
For example, /* ab "cd */" ef */ would be a valid comment. You may label
edges with flex character classes such as [^*/] and [^"]. (You needn’t be so careful
about escaping flex meta-characters.)
Problem 2
Convert the following NFA to a DFA. For each DFA state, indicate the set of NFA states
to which is corresponds. Make sure you shod the initial state and the final states in the
constructed DFA.
ε
start ε ε ε
1 2 3 4
x z y
ε ε
5 6 7
Problem 3
Consider the following grammar for regular expressions:
R→RR
R→R|R
R → R*
R → (R)
R → id
2
The start symbol is R. Note that R is the only nonterminal, and the set of terminals is
{ id, |, *, (, ) }.
Problem 4
Consider the following context-free grammar:
Grading
The problem set is worth 40 points. You will be graded on the correctness and clarity of
your answers. You may use just one late day on this assignment.