Algorithm for finding the inversions in a given array of integers using merge-sort algorithm