Add merge-sort module: top-down and bottom-up merge sort, dry runs, stability, comparison counts against the exact worst case, linked lists, counting inversions, quick sort and TimSort comparisons, and the 2015 program re-run (unstable on ties, quadratic allocation) (17 tests, 15 transcripts)
Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b6vDJ5fWY5uEZaJFNi
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
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)
|
||||
Reference in New Issue
Block a user