Basically the problem statement says that "From all the possible pairs of n bit binary strings(S1,S2 where both S1 and S2 are n bit binary strings) if we randomly select any pair then what is the probability that ,Hamming distance between the strings of that selected pair is d "

Number of binary string pairs (S1,S2) each having length n ,can be formed in 2^n * 2^n ways.

Now we have to find out the number of such pairs where hamming distance between S1,S2 is d.

In order to form such pairs first select any S1(which can be done is 2^n ways),

Now lets form S2: Select nCd positions from S2, once nCd bit positions from S2 is selected, for those positions we have only one choice(opposite of S1's value for that particular position). Remaining n-d places of S2 will have exactly same value as S1's value for those positions(this will make sure that hamming distance of S1, S2 is exactly d) hence only one way we can do so.

So , for a particular S1, we can form S2 in nCd *1 *1=nCd ways ,such that hamming distance of (S1,S2)=d.

There are 2^n ways to form S1, So total number of pairs where hamming distance is d = 2^n * nCd

We already know number of binary string pairs each having length n ,can be formed in 2^n * 2^n ways.

Hence required probability= (2^n * nCd) / ( 2^n * 2^n) = nCd/ 2^n