Question: Is Hamming function one to one?

  • Thread starter Thread starter Topgun_68
  • Start date Start date
  • Tags Tags
    Function
AI Thread Summary
The Hamming function, which calculates the number of differing bits between two binary inputs, is not one-to-one. Multiple input combinations can yield the same output, demonstrating that the function does not uniquely map inputs to outputs. For instance, both f(11100, 11101) and f(11110, 11100) return the same result of 1. The discussion highlights that with 32 possible binary inputs and only 5 output values, the function cannot be one-to-one. Therefore, the conclusion is that the Hamming function fails to meet the criteria for a one-to-one mapping.
Topgun_68
Messages
34
Reaction score
0

Homework Statement



I have a Hamming function which takes two inputs, domain & co-domain and the output is how many bits are different.

Example: f(11100, 11101) = 1 (only one bit is different).

Is this one to one?

I say no because there could be many other combinations if inputs that can produce the same answer as the output. For example f(11110, 11100) = 1 also.

I just want to know if my thinking is correct or totally off base.

Thanks for any feedback!
 
Last edited:
Physics news on Phys.org
I think you're right. If you were to plot the function using all binary numbers from 00000 to 11111 there are 32 choices but only 5 bits so the reverse mapping would have several y values for any given x value on the 0 to 5 domain.
 
I didn't even think to check it out that way. So with 32 inputs (domain) and 5 outputs (range), there's no way it can be one to one unless I'm missing something.

Now if it we're an encoding function where it would have to encode/decode back and forth, that would be one to one I think.

Thanks for the input.

jedishrfu said:
I think you're right. If you were to plot the function using all binary numbers from 00000 to 11111 there are 32 choices but only 5 bits so the reverse mapping would have several y values for any given x value on the 0 to 5 domain.
 
Topgun_68 said:

Homework Statement



I have a Hamming function which takes two inputs, domain & co-domain and the output is how many bits are different.

Example: f(11100, 11101) = 1 (only one bit is different).

Is this one to one?

I say no because there could be many other combinations if inputs that can produce the same answer as the output. For example f(11110, 11100) = 1 also.

I just want to know if my thinking is correct or totally off base.

Thanks for any feedback!

Your example shows that f is not 1:1; end of story.
 
Back
Top