CE 160
First Exam
First Semester, 2002-2003
exam date: July 18, 2002
coverage: deterministic and nondeterministic finite automata,
regular expressions (approximately chapters 2 and 3 of [IALC2] ) [ answers]
Convert the following e-NFA to an equivalent DFA in the form of a transition diagram:
e |
a |
b |
c |
|
p |
{p,q} |
{p,r} |
{p} |
|
q |
{r} |
{r} |
{r} |
{r} |
r |
{s} |
{s} |
{s} |
{s} |
*s |
[answer]
0 | 1 | |
A | B | B |
0 | 1 | |
A | A | B |
0 | 1 | |
A | B | A |
For each way of defining transitions from A, there are four ways of defining the transitions from B. And for each way of defining transitions for the DFA, there are two choices for the accepting state. This amounts to 3*4*2=24 distinct DFA's.
0 | 3,6,9 | 1,4,7 | 2,5,8 | |
A | A | [0] | [1] | [2] |
*[0] | [0] | [0] | [1] | [2] |
[1] | [1] | [1] | [2] | [0] |
[2] | [2] | [2] | [0] | [1] |
.
a | b | c | |
p | pqrs | prs | p |
*pqrs | pqrs | prs | prs |
*prs | pqrs | prs | ps |
*ps | pqrs | prs | p |
.
Draw the transition diagram.
With the added condition, we only need to monitor the quantity
n = # of 0's seen so far - # of 1's seen so far.
Based on the condition, if ever n becomes 2 or -2, the DFA should go into a dead state and stay there, since the current string violates the condition and the current string would be a prefix of whatever the full string turns out to be. We don't really need to keep track of n once we're in the dead state. The only other states we need are those corresponding n = 0, n = 1, and n = -1. The state for n = 0 is the lone accepting state and also the start state. A transition table for the DFA is
0 1 *[0] [1] [-1] [1] d [0] [-1] [0] d d d d Draw the transition diagram. In obtaining the regular expression, the dead state is very easily eliminated. Once this is done, the two nonaccepting states are eliminated and converted to loops.
Final answer: (01+10)*.
This page has been accessed
times since July 20, 2002.