Optimise quick_sort#678
Merged
vil02 merged 1 commit intoTheAlgorithms:masterfrom Mar 18, 2024
genskyff:perf/update-quick-sort
Merged
Optimise quick_sort#678vil02 merged 1 commit intoTheAlgorithms:masterfrom genskyff:perf/update-quick-sort
quick_sort#678vil02 merged 1 commit intoTheAlgorithms:masterfrom
genskyff:perf/update-quick-sort
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #678 +/- ##
=======================================
Coverage 94.71% 94.71%
=======================================
Files 293 293
Lines 23346 23351 +5
=======================================
+ Hits 22113 22118 +5
Misses 1233 1233 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
This pull request has been automatically marked as abandoned because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
vil02
approved these changes
Mar 18, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request Template
Description
If the input array is completely ordered, let's say the length of the subarray in the recursion is
m, each partition operation will result in a left subarray of length0and a right subarray of lengthm - 1. In this scenario, the height of the recursion tree will reachn - 1, requiringO(n)size of stack space.To avoid this, it's possible to compare the lengths of the two subarrays each time and only recurse on the shorter subarray. Since the length of the shorter subarray won't exceed
n / 2, this approach ensures that the recursion depth does not go beyondlog(n), thereby optimizing the worst-case space complexity tolog(n).Checklist:
cargo clippy --all -- -D warningsjust before my last commit and fixed any issue that was found.cargo fmtjust before my last commit.cargo testjust before my last commit and all tests passed.COUNTRIBUTING.mdand my code follows its guidelines.