Answered step by step
Verified Expert Solution
Question
1 Approved Answer
please complete functional requirements 1-3 Background: Consider the following finite state automaton (Scott, 2016), which recognizes the language (i.e. inputs) consisting of binary digits containing
please complete functional requirements 1-3
Background: Consider the following finite state automaton (Scott, 2016), which recognizes the language (i.e. inputs) consisting of binary digits containing a single decimal point, 90 91 0,1 0,1 0,1 92 93 0,1 0,1,. 94 Recall, a Deterministic Finite Automaton (DFA) is as quintuple Mover an alphabet 2, M = (0,8,9s,F,8) where Q is a set of states, E is a set of alphabet symbols, qs e Q is an initial state, F is a set of accepting (final) states, and d is a transition function from a current state and input alphabet symbol to a next state, 8: Q * -Q. For example, the automaton depicted above is defined as, Q = {90,91,92,93,94) = {0,1, 9s = 40 F = {93} (90,0,91),(40,1,92X90...92), (91,0,91),(91,1,91X91., 93), 8 = (92,0,93), (92, 1,93), (92...94), (93,0,93), (93, 1,93), (937.,94), 94,0,94), (94, 1,94) (94,.,94) Assignment Create a C language program that can be used to construct any arbitrary Deterministic Finite Automaton. The definition of Mabove is only one instance of DFA. Functional requirements Write a program in C that: 1. Prompts the user to ask if they want to terminate the program or to load a new DFA file. 2. Prompts for a .txt file locationame to load (see file example below), 3. Reads and loads a deterministic finite automaton (DFA) from a text file (see format below), 4. Prompt the user for an input string, 5. Test if the string is accepted by the DFA loaded in Step 3 or not, 6. Display the result. 7. Prompt the user to ask if they want to test another string or not. If yes, go to 4. If no, go to 1. 8. Your program should be modular and minimally include functions for creating a new DFA, loading an existing DFA, and executing the DFA on the user's input string. Tips: For step 5, recall that an input string is accepted, if beginning in the initial DFA state, the complete sequence of input symbols ends up transitioning to an accepting (or final) state in the DFA. - For step 3, create structs for: the automaton, a state, and a transition. For example, the automaton struct should have a "states" field, "transitions" field, etc. corresponding to the formal definition of the DFA given above (see further implementation requirements below) Non-Functional Requirements 1. Analyze each of the primary functions in your program, including the main() function. For each function give the Big-O complexity that captures the complexity of the DFA. What is the complexity class of this function (e.g. O(1), O(log n), O(n), O(na), etc.? 2. Your program must: a. demonstrate the use of C pointers, structs, malloc, sizeof, free printf, scanf, fscan, macro constants, and typedef. b. demonstrate function calling and function prototype declarations. c. Use an array to implement the "list" of states in the DFA. d. Use a linked list to implement the "list" of transitions in the DFA. You may assume the DFA will no more than 25 states. 3. Use the following example file structure/syntax to be loaded as a DFA (without the // comments) 90,91,92,93,94 q0 93 // States (alphanumeric, no space) with coma separation (no space) // Initial State // Accepting states (comma delimited no space; could be "93,94" for ex. ) // Transitions (comma delimited no space) // 'l' is the input symbol (those can be special characters but no space) // In this example, we can see that is a valid input symbol 90,0,91 90,1,91 20...22 91,0,91 94.94 // file ends with the last transitionStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started