开发者

Turing machine adding two numbers

开发者 https://www.devze.com 2022-12-15 01:13 出处:网络
How can I create Turing Machine which w开发者_JS百科ill calculate sum of two binary digits separated by #, eg. 111#101B, where B is for blank? Result can be written at the end of the tape.

How can I create Turing Machine which w开发者_JS百科ill calculate sum of two binary digits separated by #, eg. 111#101B, where B is for blank? Result can be written at the end of the tape.


  1. Write a turing machine to convert both binary numbers to unary (maintaining the blank between them).
  2. Write a turing machine to replace the blank with a 1, and chop a digit off the end.
  3. Write a turing machine to convert a unary number to binary.
  4. Chain those three machines together.


assuming input a#(1)b convert to a#(1)b#(2)c#(3)BLANK

Blank will be filled with sum. Make 2 cases for LSB of 'a'. Further divide 2 cases for LSB of 'b'. 'c' is the carry bit that is initially 0. Make seperate 2 cases for each of the four cases and update the carry bit on the way. Path is chosen based on if 'c' was 0 or 1.

Picture shows a rough sketch.

Turing machine adding two numbers

Final result will be reversed value of original sum. You reverse this again. Take the pic with a grain of salt. It is just a rough sketch. Nomenclature is not followed.

0

精彩评论

暂无评论...
验证码 换一张
取 消