Question: Attached are the files DFA.hpp and DFA.cpp for a simple data structure to represent a deterministic finite automaton. Your task is to implement the function
Attached are the files DFA.hpp and DFA.cpp for a simple data structure to represent a deterministic finite automaton. Your task is to implement the function dfa_is_accepted, which takes as input a DFA and a string, and determines if the DFA accepts the string. The version of g++ on the cs linux machines is recent as of the Summer of '15, which is to say, it is old. Please make sure it compiles there with the --std=c++11 flag, to give us a common baseline for running your code. Submit your revised version of DFA.cpp, and answer the question: how did you test your code?


1 #include #include "DFA.hpp" 2 3 4 5 6 LA bool dfa_is_accepted (const DFA &m, const std::string &w) { return true; } 7 8 9 10 11 12 13 14 15 16 std::ostream& operator > m.numStates; boost::multi_array::extent_gen extents; m.transFunc.resize (extents [2][m.numStates]); for (int q = @; q > m.transFunc [@][9]; in >> m.transFunc [1][9]; } in >> m.initialState; m. finalstates.resize (m.numStates, false); int k; in >> k; for (int i = 0; i > q; m.finalstates [9] - true; } return in; } % C DFA hpp 1 #ifndef DFA_HPE 2 #define DFA HPP 3 4 #include 5 #include 6 #include 7 8 /* numStates is the number of states in the DFA 9 10 * transFunc is the transition function. 11 * For simplicity, we number the states e..numStates-1, and assume the alphabet is {0,1}. 12 * transFunc [1][5] would be the new state we enter if we encounter a 1 in state 5. 13 14 * initialState is the initial state. 15 16 * finalstates is the set of final states. 17 * finalstates [q] is true if q is a final state, false otherwise. 18 */ 19 struct DFA { 20 int numStates; 21 boost::multi_array transFunc; 22 int initialstate; 23 std::vector finalstates; 24 }; 25 26 /* Read or write a DFA in a specific format: 27 * an integer, representing the number of states in the DFA 28 * two integers for each state, the new states reached after reading a 8 or 1 29 an integer representing the initial state 30 * the number of final states 31 a list of the final states 32 33 * For example, we could represent a DFA for strings in which the number of 1 bits is a multiple of 4: 34 * 4 35 36 * 1 2 37 38 * 3 @ 39 40 41 */ 42 std::ostream& operator