Question: In java! implement a class FiniteStateMachine for DFA. Since FSM is a 5 - tuple object, your class will have them as member fields: list

In java!
implement a class FiniteStateMachine for DFA. Since FSM is a 5-tuple object, your class will have them as member fields: list of states, list of inputs or alphabet, transition table, start state and final states.Implement the following public member functions to run input string through your FSM:boolean Execute(string s); // returns true if the string s is accepted by the FSM or false if it is rejectedint[] Path(string s); // returns an array of indices of the states the FSM runs through given the input string sWrite a set of unit tests to validate that your implementation is correct. You should include both positive and negative cases.Implement the driver code to read a specification of the FSM from file so you can build the FiniteStateMachine object. Then read a number of test strings from the same file and output whether each string is accepted or not.The input file will be of the following format:num// number of states, states are numbered from 0 to num -1string// string will contain characters for the alphabetnum// number of transitionsnum-from, char, num-to // one transition per line: num-from is the number/index of the state the transition starts from, char is the input, and the num-to is the number/index of the state the transition ends atnum// index of the start statenum1, num2, num3,// list of numbers for the indices of final statestest-string// multiple lines of test strings, one on each lineYour output will be one line per each test-string from the input file: true for accepted test strings and false for rejected test strings.Once you have the code working for DFA, adapt it to support NFA. You need to add one additional member function to determine if the FSM is DFA or NFA:bool IsDFA();// returns true for DFA and false for NFAYour submission should include support for both DFA and NFA.To implement Execute for NFA, youll have to employ backtracking.
implement a method that converts NFA to DFA:void ToDFA();// converts NFA to DFA, does nothing if FSM is already a DFASample inPut:
4
ab
8
0,a,1
0,b,0
1,a,2
1,b,0
2,a,3
2,b,0
3,a,3
3,b,3
0
0,1,2bbaaa
aba
bbbaaabba
aabbbaab
baaabab

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!