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 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 Executestring s; returns true if the string s is accepted by the FSM or false if it is rejectedint Pathstring 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 to num string string will contain characters for the alphabetnum number of transitionsnumfrom, char, numto one transition per line: numfrom is the numberindex of the state the transition starts from, char is the input, and the numto is the numberindex of the state the transition ends atnum index of the start statenum num num list of numbers for the indices of final statesteststring multiple lines of test strings, one on each lineYour output will be one line per each teststring 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:
ab
a
b
a
b
a
b
a
b
bbaaa
aba
bbbaaabba
aabbbaab
baaabab
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
