You are viewing a single comment's thread. Return to all comments →
I don't realy understand the example. Why do we have to do 4 swaps in case of this array: 2 1 3 1 2? If we swap
a[0] <-> a[3] ==> 1 1 3 2 2, and
a[2] <-> a[4] ==> 1 1 2 2 3,
we can get the sorted array.
Seems like cookies are disabled on this browser, please enable them to open this website
Merge Sort: Counting Inversions
You are viewing a single comment's thread. Return to all comments →
I don't realy understand the example. Why do we have to do 4 swaps in case of this array: 2 1 3 1 2? If we swap
a[0] <-> a[3] ==> 1 1 3 2 2, and
a[2] <-> a[4] ==> 1 1 2 2 3,
we can get the sorted array.