algorithmstring-algorithm

adversary argument for finding n-bit strings


Given:
S, a set an odd number of n-bit strings
A, a particular n-bit string

show that any algorithm that decides whether A is in S must examine all n bits of A in the worst case.

Usually of course we would expect to have to look at all the parts of a string to do the matching, but there's something particular about S having an odd size that's escaping me.


Solution

  • Let's say we have an algorithm A that decides membership in S correctly and says, for any input n-bit string, whether the string is in S or not.

    Suppose for a given input n-bit string s1, the algorithm A never looks at bit i of s1 and goes on to say "s1 is in (not in) S". Then a string s2 equal to s1 except with bit i flipped is also in (not in) S! That is, for any string we feed into A, if A doesn't look at a particular bit, then there is a second string also in (or not in) S with that bit flipped.

    Then what is special about odd-sized sets S? We can't pair up strings in S evenly. That is, there must be a string s3 that A looks at and decides is in S, for which no single bit can be flipped to form another string in S. So A must look at all the bits of s3 (otherwise we could make such a string, as we did before).