Build a Turing Machine that counts a's and b's

49 views Asked by At

Im trying to design a Turing Machine that takes as input a word formed by symbols of the alphabet Σ = {a, b} and counts, in binary, the occurrences of symbol a and the occurrences of symbol b. The final contents of the tape must correspond to the number of occurrences, in binary, of symbol b, the symbol $, the number of occurrences, in binary, of symbol a, and then the input string. The final tape should be (number of a's in binary)(th symbol"$")(number of b's)(original string of as and bs)

I was trying to build it but I dont see how can I give the outputs in binary enter image description here

UPDATE: I've managed to build one that counts a's and b's but by putting a 1, can someone help me make it count in binary instead of in units?

enter image description here

0

There are 0 answers