Answer the question
In order to leave comments, you need to log in
How to find discrepancies in array sorting?
There is a one-dimensional reference array which contains elements in the correct order. You need to compare it with another array, where the order of the elements may differ. And this discrepancy needs to be expressed by some numerical metric.
Are there any ready-made solutions for this?
Answer the question
In order to leave comments, you need to log in
If the contents of the arrays are the same, and differ only in permutations, then you can apply the Wagner-Fisher algorithm, or the Hischberg algorithm , if all operations except transposition are raised.
You can try to calculate the difference between the indices of the same element in two arrays and find the sum of these differences for all elements. Take the difference modulo, so that the pros / cons do not affect the result.
If some elements are duplicated in arrays, then you need to remember the indices of already checked elements so as not to compare them again.
firstArray.zip(secondArray).map(abs(firstElement-secondElement)
)
.
if the elements are not numbers, then you yourself need to come up with a metric to compare the elements.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question