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 @@
|
||||
Lomuto partition, traced on [15, 34, 26, 67, 95, 24]
|
||||
====================================================
|
||||
|
||||
partition [0..5] [15, 34, 26, 67, 95, 24], pivot = 24 (last)
|
||||
j=0: 15 <= 24 -> i=0, swap a[0] and a[0] [15, 34, 26, 67, 95, 24]
|
||||
j=1: 34 > 24 -> skip
|
||||
j=2: 26 > 24 -> skip
|
||||
j=3: 67 > 24 -> skip
|
||||
j=4: 95 > 24 -> skip
|
||||
place pivot: swap a[1] and a[5] [15, 24, 26, 67, 95, 34] -> pivot final at index 1
|
||||
partition [2..5] [26, 67, 95, 34], pivot = 34 (last)
|
||||
j=2: 26 <= 34 -> i=2, swap a[2] and a[2] [15, 24, 26, 67, 95, 34]
|
||||
j=3: 67 > 34 -> skip
|
||||
j=4: 95 > 34 -> skip
|
||||
place pivot: swap a[3] and a[5] [15, 24, 26, 34, 95, 67] -> pivot final at index 3
|
||||
partition [4..5] [95, 67], pivot = 67 (last)
|
||||
j=4: 95 > 67 -> skip
|
||||
place pivot: swap a[4] and a[5] [15, 24, 26, 34, 67, 95] -> pivot final at index 4
|
||||
final: [15, 24, 26, 34, 67, 95]
|
||||
|
||||
partition calls: 3
|
||||
Reference in New Issue
Block a user