Assign 3
Assign 3
2. Write a function to create (and store) a DFA from the NFA. In general a NFA can
have -transitions.
If you feel that handling -transitions is too difficult, then you may assume that the
NFA does not have -transitions, in which case you will get half the credit for this part.
a) It reads a NFA from the input file and stores it in the data structure. A sample
input file is shown below.
b) It uses the above function to convert the NFA to a DFA. It should then print
the DFA in the format described below.
c) It reads a set of input strings from another file and simulates the DFA to test
whether each string is accepted by the DFA.
3, 1, 1
1, 1, 2 1
2, 0, 2 1 0
1, e, 3
2, 0, 3
3, 0, 1 2 3
0,1
2, 1, 3
0
First line indicates the number of states, the start state and the list of accept states. Each
other line describes a state transition in the format: PresentState, Input, NextState. The
letter “e” is used in place of .
The DFA should be printed in the same format except that states of the DFA should be
printed as subsets of states of the NFA within curly brackets. For example the DFA
transits from state {2} of the DFA on input 0 to the state {2,3}. This transition should be
printed as:
{2}, 0, {2,3}