u can use BIT(Binary Indexed Tree) to count inversions. I prefer this becoz it is much easier to code BIT than merge sort.
On Apr 24, 4:25 am, سهراب ابوالفتحی <sohrab.abolfa...@gmail.com> wrote: > Let A[1..n] be an array of n distinct numbers. If i < j and A[i] > A[j], > then the pair (i,j) is called an inversion of A. Give an algorithm that > determines the number of inversions in any permutation on n elements in > tetta(n lg n) worst-case time. (with Modify merge sort.) -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.