Question: 3) Write a TM program to increment a binary number. That means go to the right end of the string, then change 1's to 0's,

3) Write a TM program to increment a binary number. That means go to the right end of the string, then change 1's to 0's, going left, until you encounter a 0. Change that 0 to a 1. In the special case where the string contains only 1s, you'll keep going until you encounter a blank, then change the blank to a 1. Now continue moving the tape head left until you reach a blank. On the blank, move right and halt. That will leave the tape head positioned over the leading bit of your result.

4) Similar to the previous problem, but decrement the number rather than incrementing it. If the number contains all zeros then the machine will halt without changing anything. To decrement a positive binary number, go to the right end of the string, then go left changing 0's to 1's until the first 1 is reached, then change the 1 to a 0.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!