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,19 @@
|
||||
Hoare partition, traced on [15, 34, 26, 67, 95, 24]
|
||||
===================================================
|
||||
|
||||
partition [0..5] [15, 34, 26, 67, 95, 24], pivot = 26 (middle, index 2)
|
||||
i stops at 1 (34), j stops at 5 (24) -> swap [15, 24, 26, 67, 95, 34]
|
||||
i=2 j=2 pointers met/crossed -> split after index 2
|
||||
partition [0..2] [15, 24, 26], pivot = 24 (middle, index 1)
|
||||
i=1 j=1 pointers met/crossed -> split after index 1
|
||||
partition [0..1] [15, 24], pivot = 15 (middle, index 0)
|
||||
i=0 j=0 pointers met/crossed -> split after index 0
|
||||
partition [3..5] [67, 95, 34], pivot = 95 (middle, index 4)
|
||||
i stops at 4 (95), j stops at 5 (34) -> swap [15, 24, 26, 67, 34, 95]
|
||||
i=5 j=4 pointers met/crossed -> split after index 4
|
||||
partition [3..4] [67, 34], pivot = 67 (middle, index 3)
|
||||
i stops at 3 (67), j stops at 4 (34) -> swap [15, 24, 26, 34, 67, 95]
|
||||
i=4 j=3 pointers met/crossed -> split after index 3
|
||||
final: [15, 24, 26, 34, 67, 95]
|
||||
|
||||
partition calls: 5
|
||||
Reference in New Issue
Block a user