Skip to content
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

Randomized version of quicksort #115

Open
anay07 opened this issue Dec 7, 2017 · 6 comments
Open

Randomized version of quicksort #115

anay07 opened this issue Dec 7, 2017 · 6 comments

Comments

@anay07
Copy link

anay07 commented Dec 7, 2017

DESCRIPTION

Randomized version of quicksort is mostly implemented in real life and is missing in the repo as it is the randomized quicksort which gives it the worst case O(nlogn) complexity and not the naive implementation.

STEPS TO REPRODUCE

EXPECTED OUTCOME

Code of randomized quicksort will be added.

ACTUAL OUTCOME

Proposed Solution [optional]

I will like to add the randomized quicksort in the quicksort folder.

@prateekiiest
Copy link
Member

@anay07 , it would be better if you can show me some graph of this randomized quick sort

@anay07
Copy link
Author

anay07 commented Dec 7, 2017

@prateekiiest ,In randomized quicksort chooses the pivot at random (and also can shuffle the array at start) .

Doing this can some significant change as shown in below graphs
Here are some comparison graphs for different input cases :
1)Sorted(Reverse)
image
image
We can see there is significant difference in this case

2)Sorted
image
image
We can see the difference is not so significant in this case

@prateekiiest
Copy link
Member

How about considering the distribution of the elements of the array?
say quick sort on array of a normal distribution and on an array of uniform distribution ?

Both cases let Pivot choice be random.

@prateekiiest prateekiiest added this to Issues in Project Euler Dec 8, 2017
@prateekiiest
Copy link
Member

@anay07 did you send a PR for this ?

@anay07
Copy link
Author

anay07 commented Dec 30, 2017

Not till now as I was not assigned the same .
Also I found that quicksort will not be affected by the distribution ( unless there are many duplicated values or if we know the range of distribution of number (as we can use bucket sort in this case which is faster than quicksort) )

@vasugr
Copy link

vasugr commented Dec 5, 2018

I would like to contribute to this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

3 participants