Commit 7a0fbe7
fix(QuickSort): use low instead of hardcoded 0 in left recursive call (#2)
The left recursive call passed a hardcoded 0 as the lower bound instead
of low, so every left-partition call re-sorted the array from index 0
rather than from the start of the current sub-problem. The result stayed
correct (the [0, low-1] prefix is already in place) but recursion work
blew up to O(n^2): on a descending array of 2000 elements the buggy
version makes 1,001,001 quickSort invocations vs 3,999 after the fix,
which is what can drive the reported StackOverflowError on large inputs.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent b995241 commit 7a0fbe7
1 file changed
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
0 commit comments