I am trying to find an efficient way to compare a given array that represents the Quality of Service of a Client with the QOS of a Two Web Services and pick up the most similar to the given QOS.
int[] arrayCompare(int[] clientQOS){
int[] service1QOS=new int[]{3,1,4};
int[] service2QOS=new int[]{1,3,3};
//I want to compare clientQOS with S1 QOS and S2 QOS
return mostSimilarArray
}
Loop through the source array for each target, incrementing a counter by the delta (positive difference between the values). The smallest delta sum is the closest match.
Caveats
This should be true if you consider numerically closer to be more similar, and the scale between different values are equal.