Reputation: 225
Can anyone explaine me how to do Turing machine for following:
Y= X mod 3, where (X, Y) binary numbers with minimum time complexity 10
Upvotes: 0
Views: 5990
Reputation: 99172
All right, you understand the algorithm, now we must build the machine.
We will start with the number 111010 (58), reading from left to right, with the machine head starting at the left. There are two modes: scanning to the right to see what is there, and moving to the left while rewriting.
|
v
x111010m
abcdefgh
(I have marked the positions a-h, for our conversation.) What should the machine do?
In a Turing machine, a state has several rules, so that the machine can decide what to do by which symbol it sees. The rules for state A can look like:
"If I see the symbol x, I will erase it and write the symbol v, move one step to the left and enter state B."
"If I see the symbol y, I will leave it undisturbed, move one step to the right and enter state D."
"If I see the symbol w, I will erase it and write the symbol z, move one step to the left end enter state A (remain in this state)."
In general, it scans to the right, to discover whether the number begins with 11, 100 or 101. This involves two different states. It then moves to the left, rewriting 11->xx, 100->xx1, 101->x10. This involves several states.
In the case of 111010, it the first few moves will look like this:
(a) In state 1, read x, leave it undisturbed, move right, remain in state 1. (Looking for 1.)
(b) In state 1, read 1, leave it undisturbed, move right, go to state 2. (What comes next?)
(c) In state 2, read 1, write x, move left, go to state 3. (Must rewrite this symbol as x and the previous one as x.)
(b) In state 3, read 1, write x, move right, go to state 1. (Looking for 1 again.)
(If you are clever you can do without state 3, but let's get the machine working first.)
So I can write some of the rules like this:
1 x x right 1
1 1 1 right 2
2 1 x left 3
3 1 x right 1
You must write enough rules that the machine always knows what to do, and if you want the machine to stop (yes!) there must be a rule -- or many rules -- like this:
5 m m right halt
Is this enough to get you started?
Upvotes: 3