Question
In case of two binary strings we can calculate hamming distance by doing XOR operation on the two strings and the number of 1 present
In case of two binary strings we can calculate hamming distance by doing XOR operation on the two strings and the number of 1 present in the result will be the Hamming Distance, for example
1 0 0 1 0 1 1 0 0 0 -------------- 0 1 0 1 0 (Hamming distance is two as number of 1 in the result is two)
Now create program to calculate the Hamming distance of two binary strings:
input() : This function will be used to take two binary strings in form of an array.
hamming(): this function will perform the XOR operation on the two inputs
count_ham(): This function will count the number of 1 in the result and will return the output.
using java netbeans
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started