Design a Turing Machine to construct the function f(n) = 4 [1/4 n] + 2, (that...

Free

80.2K

Verified Solution

Question

Mechanical Engineering

Design a Turing Machine to construct the function f(n) = 4 [1/4n] + 2, (that is, 2 more than 4 times the integer part of 1/4 n)for n Element N. Do not just produce a TM, but also describebriefly how it works. There is a TM in the Cooper notes that doessomething similar. You may modify it to produce the required TM, orproduce a machine totally independently.

Answer & Explanation Solved by verified expert
4.0 Ratings (483 Votes)

import turingMachine.State;
import turingMachine.Transition;
import turingMachine.TuringMachine;

public category AcceptReject produce the machine which will solely settle for 1's
TuringMachine atomic number 69 = new TuringMachine('q');
  

State[] alphabetic character = new State[3];
q[0] = tm.addState(State.INITIAL);
q[1] = tm.addState(State.FINAL);
q[2] = tm.addState(State.NORMAL);
  

tm.addTransition(q[0], q[0], '1', '1', Transition.RIGHT);
tm.addTransition(q[0], q[1], Transition.BLANK, Transition.BLANK, Transition.LEFT);
tm.addTransition(q[0], q[2], '0', '0', Transition.RIGHT);
  
// method input 111
if(tm.process(\"111\"))
System.out.println(\"Accept 111\");
else
System.out.println(\"Reject 111\");
  
// method input 1011
if(tm.process(\"1011\"))
System.out.println(\"Accept 1011\");
else
System.out.println(\"Reject 1011\");
}
}
import java.io.FileNotFoundException;

import turingMachine.TuringMachine;

/**
* Turing Machine
*/
public category Addition {
public static void main(String[] args) {
try {
  
// Import addition machine
TuringMachine addition = TuringMachine.inParser(\"addition\");
  
// Print addition machine
System.out.println(\"Machine content:\");
System.out.println(addition);
  
// method input
addition.process(\"1011\");
  
// Print the tape content once the method
System.out.println(\"Tape content once process '1011':\");
System.out.println(addition.getTapeSnapshot());
  
} catch (FileNotFoundException e)
  
}
}


Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students