What is the Hamming distance between 1101 and 110, if 110 is left-padded as…

2018

What is the Hamming distance between 1101 and 110, if 110 is left-padded as 0110?

Answer: B. 3The Hamming distance between two binary strings of equal length is the number of bit positions at which their corresponding bits differ. Before comparing two…

  1. A.

    2

  2. B.

    3

  3. C.

    4

  4. D.

    0

Attempted by 998 students.

Show answer & explanation

Correct answer: B

The Hamming distance between two binary strings of equal length is the number of bit positions at which their corresponding bits differ. Before comparing two strings of different lengths, the shorter one must first be padded on the left with leading zeros so both have the same length.

  1. Pad the shorter string 110 with a leading zero to match the length of 1101, giving 0110.

  2. Compare the two four-bit strings, 1101 and 0110, bit by bit at each of the four positions.

  3. Positions 1, 3, and 4 have different bits, while position 2 has the same bit in both strings.

Position

1101

0110

Match

1

1

0

Differ

2

1

1

Same

3

0

1

Differ

4

1

0

Differ

As an independent check, take the bitwise XOR of the two strings: 1101 XOR 0110 = 1011. The number of 1s in this XOR result equals the Hamming distance, and 1011 has three 1s, matching the position-by-position count above.

Since exactly three of the four bit positions differ, the Hamming distance between 1101 and (padded) 0110 is 3.

Explore the full course: Up Lt Grade Assistant Teacher 2025

Loading lesson…