Question

In: Mechanical Engineering

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

Design a Turing Machine to construct the function f(n) = 4 [1/4 n] + 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 describe briefly how it works. There is a TM in the Cooper notes that does something similar. You may modify it to produce the required TM, or produce a machine totally independently.

Solutions

Expert Solution

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)
  
}
}


Related Solutions

Design a Turing machine that, given a positive binary number n greater than or equal to...
Design a Turing machine that, given a positive binary number n greater than or equal to 2, subtracts 2 from this number. Test it, step-by-step, on the example of n = 2.
Can you give me a turing machine for the language c* n b*2n a* n+2 for...
Can you give me a turing machine for the language c* n b*2n a* n+2 for n>=0 . Please give the entire diagram with states, transition function, alphabet. Can use either one-tape or two-tape (both infinite). Describe the logic used to build the machine. Run the TM that accepts for any string of length > 1. Also run for string cbba.
Define the following function f(n) = 5(2^n)-(2^(n-1)), n ≥ 1. Write a recursive definition for the...
Define the following function f(n) = 5(2^n)-(2^(n-1)), n ≥ 1. Write a recursive definition for the function f(n)? Consider the following recurrence: an= 2an-1 + 3 (where a1 = 1). Compute the values of an for n ≤ 5. Find a solution for the recurrence definition and validate its correctness. Consider the following recurrence: an=2an-1 +an-1an-2 (where a1 = 1). Compute the values of an for n ≤ 5.
Prove that the language L={(M, N): M is a Turing machine and N is a DFA...
Prove that the language L={(M, N): M is a Turing machine and N is a DFA with L(M) =L(N)} is undecidable. You need to derive a reduction from Atm={(M, w)|Turing machine M accepts w} to L. (In layman's terms please, no other theorems involved)
Explain how a Turing Machine can simulate an arbitrary DFA. Use a 2-tape Turing Machine. It...
Explain how a Turing Machine can simulate an arbitrary DFA. Use a 2-tape Turing Machine. It can be done with a 1-Tape Turing Machine, but 2-tape will likely make the explanation more intuitive.
2. The Fibonacci sequence is defined as f(n) = f(n - 1) + f(n - 2)...
2. The Fibonacci sequence is defined as f(n) = f(n - 1) + f(n - 2) with f(0) = 0 and f(1) = 1. Find f(54) by a program or maually. Note that this number must be positive and f(53) = 53.......73 (starting with 53 and ending with 73). I must admit that my three machines including a desktop are unable to find f(54) and they quit during computation. The answer is f(54) = 86267571272 */ The Java code: public...
Fibonacci Sequence: F(0) = 1, F(1) = 2, F(n) = F(n − 1) + F(n −...
Fibonacci Sequence: F(0) = 1, F(1) = 2, F(n) = F(n − 1) + F(n − 2) for n ≥ 2 (a) Use strong induction to show that F(n) ≤ 2^n for all n ≥ 0. (b) The answer for (a) shows that F(n) is O(2^n). If we could also show that F(n) is Ω(2^n), that would mean that F(n) is Θ(2^n), and our order of growth would be F(n). This doesn’t turn out to be the case because F(n)...
Suppose f : N→N satisestherecurrencerelation f(n + 1) (f(n) 2 if f(n)iseven 3f(n)+ 1 if f(n)isodd...
Suppose f : N→N satisestherecurrencerelation f(n + 1) (f(n) 2 if f(n)iseven 3f(n)+ 1 if f(n)isodd . Notethatwiththeinitialcondition f(0) 1,thevaluesofthefunction are: f(1) 4, f(2) 2, f(3) 1, f(4) 4, and so on, the images cyclingthroughthosethreenumbers. Thus f isNOTinjective(andalso certainlynotsurjective). Mightitbeunderotherinitialconditions?3 (a) If f satisestheinitialcondition f(0) 5,is f injective? Explain whyorgiveaspecicexampleoftwoelementsfromthedomain withthesameimage. (b) If f satisestheinitialcondition f(0) 3,is f injective? Explain whyorgiveaspecicexampleoftwoelementsfromthedomain withthesameimage. (c) If f satisestheinitialcondition f(0) 27,thenitturnsoutthat f(105) 10 and no two numbers less than 105 have the same...
Let function F(n, m) outputs n if m = 0 and F(n, m − 1) +...
Let function F(n, m) outputs n if m = 0 and F(n, m − 1) + 1 otherwise. 1. Evaluate F(10, 6). 2. Write a recursion of the running time and solve it . 3. What does F(n, m) compute? Express it in terms of n and m.
The production function is f(K,N) = N/2 + √ K, where N is the amount of...
The production function is f(K,N) = N/2 + √ K, where N is the amount of labor used and K the amount of capital used. (a) What is returns to scale of this production function? What is the marginal product of labor? (b) In the short run, K¯ = 4. Labor is variable. On the graph, draw output as a function of labor input in the short run in blue. Draw the marginal product of labor as a function of...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT