Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 2: TM Computing functions from strings to strings. Create a program for TM M ab that does the following: given a string w over

Problem 2: TM Computing functions from strings to strings.

Create a program for TM Mab that does the following: given a string w over alphabet {a,b}, in the first half of w, it replaces all the a's by 1's and b's by 2's. In the 2nd half of w, it replaces all the a's by 3's and b's by 4's. If the string is odd, the middle character is replaced by 1.

This program will ACCEPT all strings of a's and b's, replace all a's and b's as described, and will always terminate with the head on the LEFTMOST tape cell.

Example: if the input string is "abbbabab", the output string is "12223434" with the head over '1'

Important: Do not use any of the same names for the states of Mab as for the states of M1234

Hint: you may want to borrow some ideas from the palindrome program available with the simulator.

Note: this is an example of a machine which computes a function; in this case, it's a function from strings to strings.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions