Write a Turing machine algorithm to perform a unary decrement. Assume that the input number may be 0, in which case a single 0 should be output on the tape to signify that the operation results in a negative number.
When writing Turing machine algorithm, include comments for each instruction or related group of instructions. The comments should convey information in terms of the algorithm the Turing machine is accomplishing. Thus, the instruction
might have a comment such as "Pass to the right over all the 0s.", but not a comment such as "In state 1 looking at a 0, write a 0, stay in state 1, and move right." which provides no additional information.
In unary representation, any unsigned whole number n is encoded by a sequence of n+1 1s. Following Turing machine instructions will perform the ...
Solution gives a turing machine that performs the unary decrement in constant time irrespective of the input size.