Question: 2. Develop a O(n log n) algorithm for computing the number of inversions in a given array 3. A permutation (or ranking) is an array
2. Develop a O(n log n) algorithm for computing the number of inversions in a given array 3. A permutation (or ranking) is an array bf N integers where cach of the integers between 0 and N-1 appears exactly once. The Kendall tau distance between two rankings is the number of pairs that are in different order in the two rankings. For example, the Kendall tau distance between 0 31625 4 and 1 0364259is four since the pairs 0-1, 3-1, 2-4 and 5-4 are in different relative order in the two rankings but all the other pairs are in the same relative order. Develop a O(n log n) algorithm for computing the Kendall tau distance between two rankings. (Hint: use the solution to the previous problem.)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
