Files
java-interview-lab/merge-sort/output/10-inversions.txt
T

14 lines
413 B
Plaintext

Counting inversions
===================
[2, 4, 1, 3, 5] 3
[38, 27, 43, 3, 9, 82, 10] 11
[1, 2, 3, 4, 5] 0
[5, 4, 3, 2, 1] 10
reversed array, n = 100,000: 4,999,950,000 (Integer.MAX_VALUE = 2,147,483,647)
the same total kept in an int: 704,982,704
[7, 7, 7, 7] ties take left : 0
[7, 7, 7, 7] ties take right: 6 (wrong: equal values are not an inversion)