1. Implement your data representation in your chosen language. 2. Write a program that implements the DFA from Figure 1.4 of the textbook as an instance of the DFA data representation that you have chosen. This program must also respond to the following stdin inputs as follows: o states: print out the states, one per line, in no particular order o alpha: print out the alphabet, one char per line, in no particular order o transitions: print out, in no particular order, each possible transition on its own line: "from" state first, followed by input char, followed by "to" state, with a space separating each. o start: print out the start state, on its own line o accepts: print out the accept states, one per line, in no particular order

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Please help me in this python code get me output of it and resolve error if posible i posted pictures of my question for your help

import sys

def main():
transition = [[[0,1],[0]], [[4],[2]], [[4],[3]], [[4],[4]]]
input = raw_input("enter the string:")
input = list(input) #copy the input in list because python strings are immutable and thus can't be changed directly
for index in range(len(input)): #parse the string of a,b in 0,1 for simplicity
if input[index]=='a':
input[index]='0'
else:
input[index]='1'

final = "3" #set of final states = {3}
start = 0

trans(transition, input, final, start)
print ("rejected")


def trans(transition, input, final, state):
for each in transition[state][int(input[0])]: #check for each possibility
if each < 4: #move further only if you are at non-hypothetical state
state = each
if len(input)==1:
if (str(state) in final): #last symbol is read and current state lies in the set of final states
print ("accepted")
sys.exit()
else:
continue
trans(transition, input[1:], final, state) #input string for next transition is input[i+1:]

main()

2. Write up an informal description of your chosen representation in a section of your
README, labeled DFA Data Representation.
For example, here's mine in Racket:
DFA Data Representation:
A State is a string
A Symbol is a 1-char string
A DFA is a (struct states alpha delta start accepts)
where:
- states is a list of State
- alpha is a list of Symbol
- delta is a hash of State Symbol -> Symbol
- start is a State
- accept is a list of State
-
Note that structs, strings, lists, and hashes are data structures in my language. Your
data representation will vary depending on your chosen language and the available
constructs in that language. For example, if you're using Java, you might choose an
Object instead of a struct.
Transcribed Image Text:2. Write up an informal description of your chosen representation in a section of your README, labeled DFA Data Representation. For example, here's mine in Racket: DFA Data Representation: A State is a string A Symbol is a 1-char string A DFA is a (struct states alpha delta start accepts) where: - states is a list of State - alpha is a list of Symbol - delta is a hash of State Symbol -> Symbol - start is a State - accept is a list of State - Note that structs, strings, lists, and hashes are data structures in my language. Your data representation will vary depending on your chosen language and the available constructs in that language. For example, if you're using Java, you might choose an Object instead of a struct.
1. Implement your data representation in your chosen language.
2. Write a program that implements the DFA from Figure 1.4 of the textbook as an
instance of the DFA data representation that you have chosen. This program must also
respond to the following stdin inputs as follows:
o states: print out the states, one per line, in no particular order
o alpha: print out the alphabet, one char per line, in no particular order
o transitions: print out, in no particular order, each possible transition on its own
line: "from" state first, followed by input char, followed by "to" state, with a space
separating each.
o start: print out the start state, on its own line
o accepts: print out the accept states, one per line, in no particular order
1
92
93
0,1
FIGURE
1.4
A finite automaton called M1 that has three states
Transcribed Image Text:1. Implement your data representation in your chosen language. 2. Write a program that implements the DFA from Figure 1.4 of the textbook as an instance of the DFA data representation that you have chosen. This program must also respond to the following stdin inputs as follows: o states: print out the states, one per line, in no particular order o alpha: print out the alphabet, one char per line, in no particular order o transitions: print out, in no particular order, each possible transition on its own line: "from" state first, followed by input char, followed by "to" state, with a space separating each. o start: print out the start state, on its own line o accepts: print out the accept states, one per line, in no particular order 1 92 93 0,1 FIGURE 1.4 A finite automaton called M1 that has three states
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Threads in linked list
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education