snippetMinor
How to find left-hand side of tape on a Turing Machine?
Viewed 0 times
lefthandhowsidetapefindturingmachine
Problem
I am pretty new to Turing Machines and am trying to figure something out. So let's say I have a tape with input
The language is twice as many 0's than 1's. So first time through, I will mark an X on the first 1 I find. Then when I am heading back to the start of the tape, how do I know when to stop? Can you "run" off the left hand side of the tape?
0 0 1 0 0 1The language is twice as many 0's than 1's. So first time through, I will mark an X on the first 1 I find. Then when I am heading back to the start of the tape, how do I know when to stop? Can you "run" off the left hand side of the tape?
Solution
for above example before you start your tape is like this ($e$ means empty and right side of $>$ is block of tape that you are reading it)
as you said you should first mark $X$ on the first $1$ and it become like this
now you should clear two zeros because the number of zeros is twice of the number of ones. you can clear the first two zero of the tape. go to the beginning of the tape like this (when you read $e$ it means you are at the beginning of tape and go one step to the right so that marker be over the first symbol of tape)
now you can mark two zeros with $X$ or $Y$ it does't matter but for readability it's better to mark it with another symbol
now go back to the beginning of tape
now it's like a for loop you should do this until there is no $1$ on the tape. when you got end of the tape while searching for $1$ it means that you ran out of ones. you should check two cases
if the first case happens while you are searching for zeros you cant find two of them and you got to the end of tape like below
become
so in this case you should reject the string.
and checking the second case is in the last step when you ran out of ones you should check that is there any zeros one the tape right now. if you found any zero you should reject.
remember never write empty over $0$ or $1$ because when you reach empty it means you are at the end or the beginning of the tape.
based on definition of Turing Machine you can run off the left hand side or not. there are Turing Machines that their tapes are infinite at the right side and finite at the left side so you can run off at the left side. but standard Turing Machine is infinite at both site so you can run off at the left hand side.
e>001001eas you said you should first mark $X$ on the first $1$ and it become like this
e00>X001enow you should clear two zeros because the number of zeros is twice of the number of ones. you can clear the first two zero of the tape. go to the beginning of the tape like this (when you read $e$ it means you are at the beginning of tape and go one step to the right so that marker be over the first symbol of tape)
e>00X001enow you can mark two zeros with $X$ or $Y$ it does't matter but for readability it's better to mark it with another symbol
eY>YX001enow go back to the beginning of tape
e>YYX001enow it's like a for loop you should do this until there is no $1$ on the tape. when you got end of the tape while searching for $1$ it means that you ran out of ones. you should check two cases
- is number of ones less than twice of zeros
- is number of ones greater than twice of zeros
if the first case happens while you are searching for zeros you cant find two of them and you got to the end of tape like below
e>00010111ebecome
eYYYXYXY1>eso in this case you should reject the string.
and checking the second case is in the last step when you ran out of ones you should check that is there any zeros one the tape right now. if you found any zero you should reject.
remember never write empty over $0$ or $1$ because when you reach empty it means you are at the end or the beginning of the tape.
based on definition of Turing Machine you can run off the left hand side or not. there are Turing Machines that their tapes are infinite at the right side and finite at the left side so you can run off at the left side. but standard Turing Machine is infinite at both site so you can run off at the left hand side.
Code Snippets
e>00010111eeYYYXYXY1>eContext
StackExchange Computer Science Q#55370, answer score: 5
Revisions (0)
No revisions yet.