Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

% run - i m 2 6 9 _ util # both files are in the downloaded TMA zip file % run - i m

%run -i m269_util # both files are in the downloaded TMA zip file
%run -i m269_tm
palindrome ={
# 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
}
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]),
('even palindrome 2', palindrome, [0,1,1,0], False, [1]),
('even palindrome 3', palindrome, [1,1,1,1], False, [1]),
('even palindrome 4', palindrome, [0,0,0,0], False, [1]),
('odd palindrome 1', palindrome, [0,1,0], False, [1]),
('odd palindrome 2', palindrome, [1,1,0,1,1], False, [1]),
('odd palindrome 3', palindrome, [0,1,1,1,0], False, [1]),
('not palindrome 1', palindrome, [1,0,0,0], False, [0]),
('not palindrome 2', palindrome, [1,1,0,0], False, [0]),
('not palindrome 3', palindrome, [0,1,1,0,1], False, [0]),
('not palindrome 4', palindrome, [1,0,1,0,1], False, [0])
]
test(run_TM, palindrome_tests)
palindrome FAILED: [] instead of [1]
not palindrome FAILED: [] instead of [0]
even palindrome 1 FAILED: [] instead of [1]
even palindrome 2 FAILED: [] instead of [1]
even palindrome 3 FAILED: [] instead of [1]
even palindrome 4 FAILED: [] instead of [1]
odd palindrome 1 FAILED: [] instead of [1]
odd palindrome 2 FAILED: [] instead of [1]
odd palindrome 3 FAILED: [] instead of [1]
not palindrome 1 FAILED: [] instead of [0]
not palindrome 2 FAILED: [] instead of [0]
not palindrome 3 FAILED: [] instead of [0]
not palindrome 4 FAILED: [] instead of [0]
Tests finished.

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

Select Healthcare Classification Systems And Databases

Authors: Katherine S. Rowell, Ann Cutrell

1st Edition

0615909760, 978-0615909769

More Books

Students also viewed these Databases questions

Question

Discuss the importance of linking pay to ethical behavior.

Answered: 1 week ago

Question

Explain how to reward individual and team performance.

Answered: 1 week ago