Question

let's say we have a tape of: xx01101011xx (x is an empty character). Could you give me an idea of an algorithm, that would say whether there's more 0 or 1? I heard about "pairing" method, but I have no idea how to use it.

Regards.

Was it helpful?

Solution

If the left-most non-blank non-X character is a 0 search right for a 1, if found change both to Xs.

If the left-most non-blank non-X character is a 1 search right for a 0, if found change both to Xs.

If a match can't be found then the left-most non-blank character exists in greater amounts. If the entire tape ends up with Xs then they exist in equal amounts.

EX with _ as blank, alphabet of {0,1,X}:

__01101011__
     v
__XX101011__
     v
__XXXX1011__
     v
__XXXXXX11__
     v
No matching 0 found, more 1s

OTHER TIPS

One approach would be to delete a 0, then seek for the next 1 and delete that, then go back and forth doing that until you have just one symbol left. This assumes you have end markers for your input.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top