Question: Q 5 ( a ) ( 1 7 marks ) Write the transition table for the Turing machine. Organise the transitions by state or by

Q5(a)(17 marks)
Write the transition table for the Turing machine. Organise the transitions by state or by the order they're executed (Section 27.1.3). Use descriptive state names.
Suggestions: Write and test a machine that handles even-length inputs and then handles odd-length inputs. 'Remove' (i.e. blank out) input symbols as you process them.
You should add tests to check your Turing machine, but you won't be awarded any marks for your tests. You don't have to remove your tests before submitting this TMA.
In palindrome_tests, set the debug parameter toTrueif you want to see the configurations your Turing machine goes through. Make sure youset it back toFalseand run the cell again before submittingyour TMA.
# State 'start', symbol read
('start',0): (None, RIGHT, 'check_right'), # Move to the right to start checking
('start',1): (None, RIGHT, 'check_right'),
# State 'check_right', symbol read
('check_right', 0): (None, RIGHT, 'check_right'), # Continue moving right
('check_right', 1): (None, RIGHT, 'check_right'),
(None, None): (None, LEFT, 'check_left'), # Encountered blank, start checking from the left
# State 'check_left', symbol read
('check_left', 0): (None, LEFT, 'compare'), # Start comparing from the left
('check_left', 1): (None, LEFT, 'compare'),
# State 'compare', symbol read
('compare',0): (0, LEFT, 'compare'), # Move left
('compare',1): (1, LEFT, 'compare'),
(None, None): (None, RIGHT, 'halt') # Reached the beginning, halt
%run -i m269_util # both files are in the downloaded TMA zip file
%run -i m269_tm
palindrome ={
}
palindrome_tests =[
# case, TM, input tape, debug, output tape
('palindrome', palindrome, [1,0,1], False, [1]),
('not palindrome', palindrome, [1,0], False, [0]),
('even palindrome 1', palindrome, [1,0,0,1], False, [1]),
]
test(run_TM, palindrome_tests)

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!