(Latest Revision: Nov 14, 2022)

Sort and Count Problem Solution


 Sorted Left Half: 10   30   31   62   71   84   89   92 (14 inversions found here)
Sorted Right Half: 42   44   48   55   70   72   77   93 (10 inversions found here)

Merge and Count Results:

Sorted Left Half-List                          Sorted Right Half-List
10   30   31   62   71   84   89   92          42   44   48   55   70   72   77   93

Merged Full List, showing the number of inversions counted for each item
10   30   31   42   44   48   55   62   70   71   72   77   84   89   92   93
 0    0    0    5    5    5    5    0    4    0    3    3    0   0     0    0  (inversions counted)


Total Inversions Found in Final Merge: 5+5+5+5+4+3+3 = 30
Grand Total of Inversions in List: 14 + 10 + 30  = 54