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,9 @@
|
||||
Sorted input, n = 100,000, on a thread with a 256 KB stack
|
||||
==========================================================
|
||||
|
||||
Lomuto.sort (recurse into both sides): StackOverflowError
|
||||
StackSafe.sort (smaller side first): sorted, deepest recursion = 2
|
||||
log2(100000) = 16.6
|
||||
|
||||
The depth at which a StackOverflowError appears depends on the JVM, the JIT state and -Xss;
|
||||
what is stable is that plain recursion needs ~n frames here and StackSafe needs at most about log2(n).
|
||||
Reference in New Issue
Block a user