Here is the question: design a turing machine that computes the number choice function:…
- User
Here is the question:
design a turing machine that computes the number choice function:
The number choice function The number choice function is defined as follows. Input: a sequence k, x1, x2, . . . , xn where • k is a positive integer. • For each i, xi is a nonnegative integer. • All these numbers are encoded in unary using repetition of the letter a , with the letter b used as a separator (in effect, playing the role of the commas). So the input sequence k, x1, x2, . . . , xn is encoded as the string a k bax1 bax2 b · · · a xn Output: xk, i.e., the k-th of the x-numbers. • This also is encoded in unary in the same way, but without any b at the end. So the output xk is encoded as the string a xk . • Recall the definition of the output of a Turing machine from Lecture 18 slide 28 (or Course Notes §18.8 p. 223). Once the machine enters the Accept state, it does not matter what comes after the leftmost blank cell; those later cells are not considered to be part of the output string. Some example inputs and outputs: input sequence input encoded as string output number output encoded as string 3,1,5,2 aaababaaaaabaa 2 aa 2,4,7,0,3 aabaaaabaaaaaaabbaaa 7 aaaaaaa 1,0,1 abba 0 ε [first tape cell must be empty] 1,3,2,0 abaaabaab 3 aaa 3,3,2,0 aaabaaabaab 0 ε [first tape cell must be empty] 0,1,5,2 babaaaaabaa undefined crash: invalid input, k = 0 4,1,5,2 aaaababaaaaabaa undefined crash: invalid input, k > n Notes: • Any input string that is not of the specified form should be rejected, by crashing. Examples of situations that must lead to a crash include: k = 0; k > n. • You can, and should, have extra letters in your tape alphabet that are not in the input alphabet {a,b}.
For this question I solved it with the following transition table. I want you to explain exactly how it works with both a high level overview and a step by step explanation. I also want you to talk about what it does do well, what it doesn't do so well, what are some better alternatives that would produce the same results in a different way (doesn't have to be the most efficient but it must work).
state read write move head next state start a A right get start b or _ right reject get a _ right findb get B _ right wipe get b _ right keep findb a or B right findb findb b B left rewind findb _ left reject rewind a or B left rewind rewind _ right get wipe a or B _ right wipe wipe b _ right keep wipe _ left reject keep a right keep keep _ left pickup keep b _ right trim trim a or b _ right trim trim _ left pickup pickup a _ left roll pickup _ left pickup pickup A _ accept roll a left roll roll _ a right right right a right right right _ left pickup roll A a accept
- Assistant