-
-
Notifications
You must be signed in to change notification settings - Fork 46.8k
Update the QuickSort Algorithm to minimise chance of O(n^2) #6095
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I can fix this |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Hi @faiqali1, I would like to contribute in this issue. Is it still open? |
I would like to work on this issue. |
Hi @mahi072 And @Ashutosh2613, Yeah, the issue is still open. Apologies for the late reply. The current issue, as stated in the title is that, it is better to choose the pivot at a random point then choosing the last element every time. So using the Random module, choose a Random point between 0 & the length of the array and use that as a pivot. |
HI @faiqali1! I'm new to contribution process. I can't find how fork this question, but here is the code:
|
@faiqali1 Changes are made, please do review the changes! |
@faiqali1 heyyy shall i work on this? |
As described in TheAlgorithms#6095, this reduces the chances to observe a O(n^2) complexity. Here, `collection.pop(pivot_index)` is avoided for performance reasons.
As described in TheAlgorithms#6095, this reduces the chances to observe a O(n^2) complexity. Here, `collection.pop(pivot_index)` is avoided for performance reasons. Fixes TheAlgorithms#6095
As described in TheAlgorithms#6095, this reduces the chances to observe a O(n^2) complexity. Here, `collection.pop(pivot_index)` is avoided for performance reasons. Fixes: TheAlgorithms#6095
Uh oh!
There was an error while loading. Please reload this page.
According to this question on StackOverflow it is better to use the median or a random value as a pivot.
Currently the implementation uses the last element as the pivot.
The text was updated successfully, but these errors were encountered: