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:
Claude
2026-11-25 22:58:21 +05:30
parent 515302d5ba
commit 6e5764978f
40 changed files with 1765 additions and 0 deletions
+14
View File
@@ -0,0 +1,14 @@
Hoare mistakes that look reasonable
===================================
1. last element as pivot with Hoare's (lo,p) / (p+1,hi) recursion, input [1, 2]:
StackOverflowError (the partition returns p = 1 = hi, so (lo, p) is the same range again)
2. Hoare partition, but recursing on (lo, p-1) and (p+1, hi) as Lomuto does, input [2, 3, 1]:
result [2, 1, 3] (expected [1, 2, 3])
all 6 permutations of 1..3: 1 come back unsorted
all 24 permutations of 1..4: 8 come back unsorted
all 120 permutations of 1..5: 52 come back unsorted
the real Hoare.sort on the same input: [1, 2, 3]