Question: # Given an positive integer x that is divisible by 3 , your TM will output x / 3 . For example, if input is

# Given an positive integer x that is divisible by 3, your TM will output x/3. For example, if input is 6, output is 2; if input is 3, output is 1
input ="111111";
blank ="";
start = q0;
accept = qf;
# Mark three 1s as x
-q01[x, r, q1] # Start marking
x [x, r, q0] # Skip marked
""["", r, qr]; # Reject
-q11[x, r, q2] # Mark second
x [x, r, q1] # Skip marked
""["", r, qr]; # Reject
-q21[x, r, q3] # Mark third
x [x, r, q2] # Skip marked
""["", r, qr]; # Reject
# Process group and check for more
-q3 x [x, r, q3] # Skip marked x's
1[1, r, q3] # Skip unmarked 1s
""[1, l, q4]; # At end: write 1, start convert
# Convert marked back
-q4 x [1, l, q4] # Convert x to 1
1[1, l, q4] # Skip 1s
""["", r, q5]; # Done converting
# Check if done
-q51[1, r, q0] # More to process
""["", r, qf]; # All done
-qf;
-qr;
correct it for me please, if it's not correct fix it?

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 Programming Questions!