Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

[JAVA TURING MACHINE] public class Project10 { public static void main(String[] args) { String[] delta = { q0 a q0 _ R, q0 _ q1

[JAVA TURING MACHINE]

image text in transcribed

public class Project10

{

public static void main(String[] args) {

String[] delta = {

"q0 a q0 _ R",

"q0 _ q1 _ R",

"q0 b q2 b L",

"q1 a q1 a R",

"q1 _ q3 b R",

"q1 b q2 a R"

};

TM turing =

new TM(delta, "q0", "q2", "q3");

turing.run("aabb");

System.out.println();

turing

.run("aa");

}

}

Implement the following Java class TMto simulate a deterministic Turing machine. public class TM public TM (String delta String go String ga String gr) public void run (String w States are represented by alphanumeric strings. A Turing machine is specified by the parameters to the constructor. The array delta defines the transition function. Each string in delta has the form "g X p Y D", representing a transition from state q to p with the label X- Y,D. The parameters go, ga, and ar define the start, accept, and reject states respectively. The blank symbol is represented by the underscore The method run simulates the computations of the TM on the input w and prints the sequence of configurations to the console. If the TM halts, it also prints "ACCEPT" or "REJECT". A test program and its output are shown below goaabb public class Project10 public static void main (String LJ args) f goabb String delta gobb q2 bb go a q0 R'' ACCEPT R" go b g2 b L'' goaa. q1 a q1 a R goa q1 3 b R "gl b g2 a R'' q1 bq3 TM turing new TM (delta "go", "q2", "q3"); REJECT turing. run aabb"); System. out. println i turing run ("aa")

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Security XI Status And Prospects

Authors: T.Y. Lin, Shelly Qian

1st Edition

0412820900, 978-0412820908

More Books

Students also viewed these Databases questions