Counting inversions in an array

前端 未结 30 2671
死守一世寂寞
死守一世寂寞 2020-11-22 04:14

I\'m designing an algorithm to do the following: Given array A[1... n], for every i < j, find all inversion pairs such that A[i] > A[j]

30条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-22 04:47

    Check this out: http://www.cs.jhu.edu/~xfliu/600.363_F03/hw_solution/solution1.pdf

    I hope that it will give you the right answer.

    • 2-3 Inversion part (d)
    • It's running time is O(nlogn)

提交回复
热议问题