Answered step by step
Verified Expert Solution
Question
1 Approved Answer
# Usage: # python 3 dfa.py 0 1 1 0 0 1 0 # Write a dimulator of a deterministic finite automata import numpy as
# Usage:
# python dfa.py
# Write a dimulator of a deterministic finite automata
import numpy as np
import sys
alphabet
states qr
acceptingstates q
transition npemptylenstateslenalphabet dtypeU
transitionstatesindexqalphabet.indexr
transitionstatesindexqalphabet.indexq
transitionstatesindexralphabet.indexq
transitionstatesindexralphabet.indexr
def DFAinput:
currentstate states
for symbol in input:
currentstate transitionstatesindexcurrentstatealphabet.indexsymbol
return currentstate
def main:
inputstring input
finalstate DFAinputstring
if finalstate in acceptingstates:
printAccept
else:
printReject
if namemain:
main
Step 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