Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Hamming distance

807607Nov 21 2006 — edited Nov 21 2006
The Hamming distance between two vectors is the number of positions in which the vectors differ. For example, the Hamming distance between 100 and 010 is 2. A binary Gray code is a subset sequence in which the Hamming distance between any pair of consecutive vectors(called codewords) is 1. The three-element subset sequence 000, 100, 110, 010, 011, 111, 101,001 is a Gray code. A Gray code may be compactly represented by giving the sequence of positions in which the vectors change. For the three-element Gray code, the position change sequence is 1, 2, 1, 3, 1, 2, 1.
g(n) is the position change sequence for a Gray code with n elements. g(n) can be obtained by the following recursive definition:
 
    g(n) = 1   for n = 1;
    g(n) =  g(n - 1) ,  n,  g(n - 1)   for n > 1
what dose it mean g(n) = g(n - 1) , n, g(n - 1) for n > 1
if we write like this:
If (n = = 1 )
 Return g(n)=1;

Else if (n>1)
Return  g(n-1)
But what is n and the second g(n - 1)
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 19 2006
Added on Nov 21 2006
2 comments
335 views