Add quick-sort module: Lomuto and Hoare partition dry runs, comparison/swap/depth counts on sorted, reverse and all-equal input, random pivot, three-way partition, recursion into the smaller side, and the three 2015 programs re-run (one corrupts duplicates, one throws) (16 tests, 14 transcripts)
Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b7Rercfj3dzDQowoFA
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
What Arrays.sort really does (read from this JDK's lib/src.zip)
|
||||
===============================================================
|
||||
|
||||
JDK: 25.0.5.1+2-LTS
|
||||
|
||||
java/util/Arrays.java:
|
||||
99 DualPivotQuicksort.sort(a, 0, 0, a.length);
|
||||
1034 public static void sort(Object[] a) {
|
||||
1223 public static <T> void sort(T[] a, Comparator<? super T> c) {
|
||||
1038 ComparableTimSort.sort(a, 0, a.length, null, 0, 0); (inside sort(Object[]))
|
||||
lines in Arrays.java that call TimSort.sort(: 8
|
||||
|
||||
java/util/DualPivotQuicksort.java, the constants and the fallback:
|
||||
69 private static final int MAX_INSERTION_SORT_SIZE = 44;
|
||||
64 private static final int MAX_MIXED_INSERTION_SORT_SIZE = 65;
|
||||
119 private static final int DELTA = 3 << 1;
|
||||
124 private static final int MAX_RECURSION_DEPTH = 64 * DELTA;
|
||||
285 if ((bits += DELTA) > MAX_RECURSION_DEPTH) {
|
||||
286 heapSort(a, low, high);
|
||||
287 return;
|
||||
288 }
|
||||
Reference in New Issue
Block a user